Compare commits

...

11 Commits

667 changed files with 78846 additions and 35162 deletions

374
README.md
View File

@ -1,189 +1,189 @@
# Joomla Component Builder ([JCB](https://www.joomlacomponentbuilder.com))
This is a [Joomla 3.x](https://extensions.joomla.org/extension/component-builder/) component. [__See In Action__](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
![Component Builder image](https://git.vdm.dev/joomla/Component-Builder/raw/branch/master/admin/assets/images/jcb-banner.jpg "The Component Builder")
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!
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.12) 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)
Once installed upgrades are quick and easy via the default [Joomla](https://extensions.joomla.org/extension/component-builder/) upgrade area.
Some of the Features
====================
+ Fetch Code from IDE and place it back in component during next compilation.
+ Add [Joomla custom fields](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=75) in any of your components.
+ Add you [own dashboard](https://www.youtube.com/watch?v=tU7TeYn1Djo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=60) in the back-end.
+ [Dynamic File and Folder](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=56) Inclusion concept.
+ [Easy Translation](https://www.youtube.com/watch?v=q5NwKGnOHoQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=51) via excel.
+ Adding your [own rule validation](https://www.youtube.com/watch?v=Z6-ggKtX35o&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=46) to a field in [JCB](https://www.joomlacomponentbuilder.com)
+ [Automated backup system](https://www.youtube.com/watch?v=GUWZaODo_IM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=40) in [JCB](https://www.joomlacomponentbuilder.com).
+ Adding mySQL Dump to any View/Table.
+ Grab existing Table data and build a dynamic dump.
+ Unlimited [Joomla](https://extensions.joomla.org/extension/component-builder/) Components.
+ Unlimited Tables/Views.
+ Reusing Views and Fields.
+ Runs on Your Own [Joomla](https://extensions.joomla.org/extension/component-builder/) Install.
+ Add Dynamic/custom back-end views that uses Table and Chart result sets.
+ Build data query of extreme complex nature to use in Dynamic/custom views.
+ Highly Dynamic/custom Front-end Structures.
+ Dynamically setup templates and layouts for Front-end design.
+ Integration of the excellent UIKIT lib.
+ Integration of the excellent FOOTABLE lib.
+ All [Joomla](https://extensions.joomla.org/extension/component-builder/) Standard Field Types (including subforms).
+ Strong Implementation of all [Joomla](https://extensions.joomla.org/extension/component-builder/) Form Security.
+ Load data via ajax with ease.
+ You can add an Update Server to Components you build.
+ Build advanced Dynamic front-end forms.
+ Dynamic data queries from multiple tables.
+ Place in local GIT folder, and publish to sales server.
+ Include any amount of custom files and folders during build.
+ Static helper class with smart methods already included.
+ Static helper methods Can easily be added.
+ Direct install from compiler view.
+ Integrative with native [Joomla](https://extensions.joomla.org/extension/component-builder/) Categories and Tags.
+ Fully Dynamic Search Friendly URL Auto Implementation.
+ Custom scripting options all over the MVC structure.
+ Permission implementation down to each view, item and field.
+ Easy extendible to include other libraries.
+ Can include SQL and visioning update link to distribute your component updates via [Joomla](https://extensions.joomla.org/extension/component-builder/) default upgrade of components.
+ Easy Export & Import addon to all backend-tables.
+ Overriding ability of import concepts in all backend-tables.
+ The Batch and Filter implementation on all backend-list views.
+ This and much much more are all possible with this component builder!
Just Imagine
====================
+ Your Component Back-end can be more advanced then the [Joomla](https://extensions.joomla.org/extension/component-builder/) Article Manager.
+ Your Code as Perfectly Unified to the strict [Joomla](https://extensions.joomla.org/extension/component-builder/) Standards.
+ Adding Custom Scripting almost anywhere in the MVC structure.
+ Import and export feature to all backend-views.
+ Batch copy and move/update feature for all backend-views.
+ History tracking per/change made on any back-end item.
+ Dynamic field control, to show and hide fields in amazing ways.
+ Front-end freedom of design that allows for any library to be used.
+ This and much much more are all possible with this component builder!
You are in Control
====================
+ You can change the licensing template for your components.
+ You can change/improve existing field types and add more.
+ Line numbers to show where in compiler was the code build.
+ You can improve the component since all code are open-source.
+ Free updates for the lifetime of the project.
+ You can dynamically add internal help structures to all component.
+ There is no limitations on how big or how much you want to build (server limitation only).
+ This is a complete factory kind of component that functions like a deployment hub.
+ Export any component completely mapped in [JCB](https://www.joomlacomponentbuilder.com) and import into another [JCB](https://www.joomlacomponentbuilder.com).
+ This and much much more are all possible with this component builder!
Get More Demo Content
====================
> You can now get access to the WOW factor, [JCB](https://www.joomlacomponentbuilder.com) fully mapped can now be yours! Including many other [JCB](https://www.joomlacomponentbuilder.com) mapped components.
### All you need to do is [explained here](https://vdm.bz/how-to-get-free-vdm-package-keys)!
To install these packages [watch this tutorial](https://vdm.bz/how-to-install-jcb-packages).
Where can you get support and help?
====================
+ [The JCB Tutorials](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE)
+ [German Basic Introduction](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wu0tDFxJtZFwW7AxA4JHQV7)
+ [Hello World Tutorial](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
+ [The JCB! Wiki](https://git.vdm.dev/joomla/Component-Builder/wiki)
+ [Forum](https://vdm.bz/jcb-forum)
+ [Report a Security Issue](https://www.joomlacomponentbuilder.com/report-security-issues)
+ [Community Complaint](https://www.joomlacomponentbuilder.com/community-complaint)
+ [Open Issue On Gitea](https://git.vdm.dev/joomla/Component-Builder/issues) ^^
Since [JCB](https://www.joomlacomponentbuilder.com) has [become a community](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/SUPPORT.md) project [VDM.io](https://www.vdm.io/) is **no longer solely responsible** for support.
We have started a [**JCB forum**](https://vdm.bz/jcb-forum) where you can post questions, about how things work, or if you need some kind of help in relation to your development of your components.
^^ Then if you run into any issues, related to the [JCB](https://git.vdm.dev/joomla/Component-Builder/issues) code, like bugs, **start by searching** the (*open & closed*) issues over on [Gitea](https://git.vdm.dev/joomla/Component-Builder/issues), and if the issue has not been mentioned before, **then only** open a new issue, following the [community guidelines](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/CONTRIBUTING.md).
WHY GIVE IT AWAY LIKE THIS?
====================
> We are Open Source Enthusiast
> Who Support the [Joomla](https://extensions.joomla.org/extension/component-builder/) Community
Our idea was to almost let this tool serve as a cheat sheet to how things can be done... and with the help of other developers end up formulating the way how things not only can, but must be done to insure secure, stable, scalable and maintainable code is produced.
MAKING IT BETTER!
====================
Get involved on the forums, and the Gitea issues, and you can even help us develop/improve the pipeline of [JCB](https://www.joomlacomponentbuilder.com) for continues delivery. We really want to see [JCB](https://www.joomlacomponentbuilder.com) remain the tool of choice for all [Joomla Component Development](https://extensions.joomla.org/extension/component-builder/) needs and ideas.
TODO
======
- Add automatic unit testing. To nurture pipeline integration for all components build with [JCB](https://www.joomlacomponentbuilder.com).
- Team collaborative development across [JCB](https://www.joomlacomponentbuilder.com) installations offline and online.
- Documentation (maintained by the community) for [JCB](https://www.joomlacomponentbuilder.com). (help us select the best system for this)
# Build Details
+ *Community*: [Vast Development Method](https://dev.vdm.io)
+ *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*: 13th November, 2022
+ *Version*: 3.1.12
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **334311**
+ *Field count*: **2004**
+ *File count*: **2183**
+ *Folder count*: **381**
> 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:llewellyn@joomlacomponentbuilder.com)
# Joomla Component Builder ([JCB](https://www.joomlacomponentbuilder.com))
## Contributors
This project exists thanks to all the people who contribute to the [Joomla Component Builder Project](https://github.com/vdm-io/Joomla-Component-Builder).
[![Contributors](https://opencollective.com/Joomla-Component-Builder/contributors.svg?width=890&button=false)](https://github.com/vdm-io/Joomla-Component-Builder/graphs/contributors)
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/Joomla-Component-Builder#backer)]
[![Our Backers on opencollective](https://opencollective.com/Joomla-Component-Builder/backers.svg?width=890)](https://opencollective.com/Joomla-Component-Builder#backers)
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/Joomla-Component-Builder#sponsor)]
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/0/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/0/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/1/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/1/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/2/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/2/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/3/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/3/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/4/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/4/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/5/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/5/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/6/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/6/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/7/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/7/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/8/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/8/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/9/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/9/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/10/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/10/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/11/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/11/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/12/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/12/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/13/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/13/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/14/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/14/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/15/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/15/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/16/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/16/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/17/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/17/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/18/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/18/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/19/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/19/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/20/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/20/website)
This is a [Joomla 3.x](https://extensions.joomla.org/extension/component-builder/) component. [__See In Action__](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
![Component Builder image](https://git.vdm.dev/joomla/Component-Builder/raw/branch/master/admin/assets/images/jcb-banner.jpg "The Component Builder")
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!
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.13) 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)
Once installed upgrades are quick and easy via the default [Joomla](https://extensions.joomla.org/extension/component-builder/) upgrade area.
Some of the Features
====================
+ Fetch Code from IDE and place it back in component during next compilation.
+ Add [Joomla custom fields](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=75) in any of your components.
+ Add you [own dashboard](https://www.youtube.com/watch?v=tU7TeYn1Djo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=60) in the back-end.
+ [Dynamic File and Folder](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=56) Inclusion concept.
+ [Easy Translation](https://www.youtube.com/watch?v=q5NwKGnOHoQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=51) via excel.
+ Adding your [own rule validation](https://www.youtube.com/watch?v=Z6-ggKtX35o&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=46) to a field in [JCB](https://www.joomlacomponentbuilder.com)
+ [Automated backup system](https://www.youtube.com/watch?v=GUWZaODo_IM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=40) in [JCB](https://www.joomlacomponentbuilder.com).
+ Adding mySQL Dump to any View/Table.
+ Grab existing Table data and build a dynamic dump.
+ Unlimited [Joomla](https://extensions.joomla.org/extension/component-builder/) Components.
+ Unlimited Tables/Views.
+ Reusing Views and Fields.
+ Runs on Your Own [Joomla](https://extensions.joomla.org/extension/component-builder/) Install.
+ Add Dynamic/custom back-end views that uses Table and Chart result sets.
+ Build data query of extreme complex nature to use in Dynamic/custom views.
+ Highly Dynamic/custom Front-end Structures.
+ Dynamically setup templates and layouts for Front-end design.
+ Integration of the excellent UIKIT lib.
+ Integration of the excellent FOOTABLE lib.
+ All [Joomla](https://extensions.joomla.org/extension/component-builder/) Standard Field Types (including subforms).
+ Strong Implementation of all [Joomla](https://extensions.joomla.org/extension/component-builder/) Form Security.
+ Load data via ajax with ease.
+ You can add an Update Server to Components you build.
+ Build advanced Dynamic front-end forms.
+ Dynamic data queries from multiple tables.
+ Place in local GIT folder, and publish to sales server.
+ Include any amount of custom files and folders during build.
+ Static helper class with smart methods already included.
+ Static helper methods Can easily be added.
+ Direct install from compiler view.
+ Integrative with native [Joomla](https://extensions.joomla.org/extension/component-builder/) Categories and Tags.
+ Fully Dynamic Search Friendly URL Auto Implementation.
+ Custom scripting options all over the MVC structure.
+ Permission implementation down to each view, item and field.
+ Easy extendible to include other libraries.
+ Can include SQL and visioning update link to distribute your component updates via [Joomla](https://extensions.joomla.org/extension/component-builder/) default upgrade of components.
+ Easy Export & Import addon to all backend-tables.
+ Overriding ability of import concepts in all backend-tables.
+ The Batch and Filter implementation on all backend-list views.
+ This and much much more are all possible with this component builder!
Just Imagine
====================
+ Your Component Back-end can be more advanced then the [Joomla](https://extensions.joomla.org/extension/component-builder/) Article Manager.
+ Your Code as Perfectly Unified to the strict [Joomla](https://extensions.joomla.org/extension/component-builder/) Standards.
+ Adding Custom Scripting almost anywhere in the MVC structure.
+ Import and export feature to all backend-views.
+ Batch copy and move/update feature for all backend-views.
+ History tracking per/change made on any back-end item.
+ Dynamic field control, to show and hide fields in amazing ways.
+ Front-end freedom of design that allows for any library to be used.
+ This and much much more are all possible with this component builder!
You are in Control
====================
+ You can change the licensing template for your components.
+ You can change/improve existing field types and add more.
+ Line numbers to show where in compiler was the code build.
+ You can improve the component since all code are open-source.
+ Free updates for the lifetime of the project.
+ You can dynamically add internal help structures to all component.
+ There is no limitations on how big or how much you want to build (server limitation only).
+ This is a complete factory kind of component that functions like a deployment hub.
+ Export any component completely mapped in [JCB](https://www.joomlacomponentbuilder.com) and import into another [JCB](https://www.joomlacomponentbuilder.com).
+ This and much much more are all possible with this component builder!
Get More Demo Content
====================
> You can now get access to the WOW factor, [JCB](https://www.joomlacomponentbuilder.com) fully mapped can now be yours! Including many other [JCB](https://www.joomlacomponentbuilder.com) mapped components.
### All you need to do is [explained here](https://vdm.bz/how-to-get-free-vdm-package-keys)!
To install these packages [watch this tutorial](https://vdm.bz/how-to-install-jcb-packages).
Where can you get support and help?
====================
+ [The JCB Tutorials](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE)
+ [German Basic Introduction](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wu0tDFxJtZFwW7AxA4JHQV7)
+ [Hello World Tutorial](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
+ [The JCB! Wiki](https://git.vdm.dev/joomla/Component-Builder/wiki)
+ [Forum](https://vdm.bz/jcb-forum)
+ [Report a Security Issue](https://www.joomlacomponentbuilder.com/report-security-issues)
+ [Community Complaint](https://www.joomlacomponentbuilder.com/community-complaint)
+ [Open Issue On Gitea](https://git.vdm.dev/joomla/Component-Builder/issues) ^^
Since [JCB](https://www.joomlacomponentbuilder.com) has [become a community](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/SUPPORT.md) project [VDM.io](https://www.vdm.io/) is **no longer solely responsible** for support.
We have started a [**JCB forum**](https://vdm.bz/jcb-forum) where you can post questions, about how things work, or if you need some kind of help in relation to your development of your components.
^^ Then if you run into any issues, related to the [JCB](https://git.vdm.dev/joomla/Component-Builder/issues) code, like bugs, **start by searching** the (*open & closed*) issues over on [Gitea](https://git.vdm.dev/joomla/Component-Builder/issues), and if the issue has not been mentioned before, **then only** open a new issue, following the [community guidelines](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/CONTRIBUTING.md).
WHY GIVE IT AWAY LIKE THIS?
====================
> We are Open Source Enthusiast
> Who Support the [Joomla](https://extensions.joomla.org/extension/component-builder/) Community
Our idea was to almost let this tool serve as a cheat sheet to how things can be done... and with the help of other developers end up formulating the way how things not only can, but must be done to insure secure, stable, scalable and maintainable code is produced.
MAKING IT BETTER!
====================
Get involved on the forums, and the Gitea issues, and you can even help us develop/improve the pipeline of [JCB](https://www.joomlacomponentbuilder.com) for continues delivery. We really want to see [JCB](https://www.joomlacomponentbuilder.com) remain the tool of choice for all [Joomla Component Development](https://extensions.joomla.org/extension/component-builder/) needs and ideas.
TODO
======
- Add automatic unit testing. To nurture pipeline integration for all components build with [JCB](https://www.joomlacomponentbuilder.com).
- Team collaborative development across [JCB](https://www.joomlacomponentbuilder.com) installations offline and online.
- Documentation (maintained by the community) for [JCB](https://www.joomlacomponentbuilder.com). (help us select the best system for this)
# Build Details
+ *Community*: [Vast Development Method](https://dev.vdm.io)
+ *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*: 29th January, 2023
+ *Version*: 3.1.13
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **360674**
+ *Field count*: **2009**
+ *File count*: **2314**
+ *Folder count*: **408**
> 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:llewellyn@joomlacomponentbuilder.com)
## Contributors
This project exists thanks to all the people who contribute to the [Joomla Component Builder Project](https://github.com/vdm-io/Joomla-Component-Builder).
[![Contributors](https://opencollective.com/Joomla-Component-Builder/contributors.svg?width=890&button=false)](https://github.com/vdm-io/Joomla-Component-Builder/graphs/contributors)
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/Joomla-Component-Builder#backer)]
[![Our Backers on opencollective](https://opencollective.com/Joomla-Component-Builder/backers.svg?width=890)](https://opencollective.com/Joomla-Component-Builder#backers)
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/Joomla-Component-Builder#sponsor)]
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/0/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/0/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/1/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/1/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/2/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/2/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/3/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/3/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/4/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/4/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/5/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/5/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/6/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/6/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/7/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/7/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/8/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/8/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/9/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/9/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/10/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/10/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/11/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/11/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/12/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/12/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/13/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/13/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/14/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/14/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/15/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/15/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/16/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/16/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/17/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/17/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/18/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/18/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/19/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/19/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/20/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/20/website)

View File

@ -1,189 +1,189 @@
# Joomla Component Builder ([JCB](https://www.joomlacomponentbuilder.com))
This is a [Joomla 3.x](https://extensions.joomla.org/extension/component-builder/) component. [__See In Action__](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
![Component Builder image](https://git.vdm.dev/joomla/Component-Builder/raw/branch/master/admin/assets/images/jcb-banner.jpg "The Component Builder")
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!
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.12) 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)
Once installed upgrades are quick and easy via the default [Joomla](https://extensions.joomla.org/extension/component-builder/) upgrade area.
Some of the Features
====================
+ Fetch Code from IDE and place it back in component during next compilation.
+ Add [Joomla custom fields](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=75) in any of your components.
+ Add you [own dashboard](https://www.youtube.com/watch?v=tU7TeYn1Djo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=60) in the back-end.
+ [Dynamic File and Folder](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=56) Inclusion concept.
+ [Easy Translation](https://www.youtube.com/watch?v=q5NwKGnOHoQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=51) via excel.
+ Adding your [own rule validation](https://www.youtube.com/watch?v=Z6-ggKtX35o&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=46) to a field in [JCB](https://www.joomlacomponentbuilder.com)
+ [Automated backup system](https://www.youtube.com/watch?v=GUWZaODo_IM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=40) in [JCB](https://www.joomlacomponentbuilder.com).
+ Adding mySQL Dump to any View/Table.
+ Grab existing Table data and build a dynamic dump.
+ Unlimited [Joomla](https://extensions.joomla.org/extension/component-builder/) Components.
+ Unlimited Tables/Views.
+ Reusing Views and Fields.
+ Runs on Your Own [Joomla](https://extensions.joomla.org/extension/component-builder/) Install.
+ Add Dynamic/custom back-end views that uses Table and Chart result sets.
+ Build data query of extreme complex nature to use in Dynamic/custom views.
+ Highly Dynamic/custom Front-end Structures.
+ Dynamically setup templates and layouts for Front-end design.
+ Integration of the excellent UIKIT lib.
+ Integration of the excellent FOOTABLE lib.
+ All [Joomla](https://extensions.joomla.org/extension/component-builder/) Standard Field Types (including subforms).
+ Strong Implementation of all [Joomla](https://extensions.joomla.org/extension/component-builder/) Form Security.
+ Load data via ajax with ease.
+ You can add an Update Server to Components you build.
+ Build advanced Dynamic front-end forms.
+ Dynamic data queries from multiple tables.
+ Place in local GIT folder, and publish to sales server.
+ Include any amount of custom files and folders during build.
+ Static helper class with smart methods already included.
+ Static helper methods Can easily be added.
+ Direct install from compiler view.
+ Integrative with native [Joomla](https://extensions.joomla.org/extension/component-builder/) Categories and Tags.
+ Fully Dynamic Search Friendly URL Auto Implementation.
+ Custom scripting options all over the MVC structure.
+ Permission implementation down to each view, item and field.
+ Easy extendible to include other libraries.
+ Can include SQL and visioning update link to distribute your component updates via [Joomla](https://extensions.joomla.org/extension/component-builder/) default upgrade of components.
+ Easy Export & Import addon to all backend-tables.
+ Overriding ability of import concepts in all backend-tables.
+ The Batch and Filter implementation on all backend-list views.
+ This and much much more are all possible with this component builder!
Just Imagine
====================
+ Your Component Back-end can be more advanced then the [Joomla](https://extensions.joomla.org/extension/component-builder/) Article Manager.
+ Your Code as Perfectly Unified to the strict [Joomla](https://extensions.joomla.org/extension/component-builder/) Standards.
+ Adding Custom Scripting almost anywhere in the MVC structure.
+ Import and export feature to all backend-views.
+ Batch copy and move/update feature for all backend-views.
+ History tracking per/change made on any back-end item.
+ Dynamic field control, to show and hide fields in amazing ways.
+ Front-end freedom of design that allows for any library to be used.
+ This and much much more are all possible with this component builder!
You are in Control
====================
+ You can change the licensing template for your components.
+ You can change/improve existing field types and add more.
+ Line numbers to show where in compiler was the code build.
+ You can improve the component since all code are open-source.
+ Free updates for the lifetime of the project.
+ You can dynamically add internal help structures to all component.
+ There is no limitations on how big or how much you want to build (server limitation only).
+ This is a complete factory kind of component that functions like a deployment hub.
+ Export any component completely mapped in [JCB](https://www.joomlacomponentbuilder.com) and import into another [JCB](https://www.joomlacomponentbuilder.com).
+ This and much much more are all possible with this component builder!
Get More Demo Content
====================
> You can now get access to the WOW factor, [JCB](https://www.joomlacomponentbuilder.com) fully mapped can now be yours! Including many other [JCB](https://www.joomlacomponentbuilder.com) mapped components.
### All you need to do is [explained here](https://vdm.bz/how-to-get-free-vdm-package-keys)!
To install these packages [watch this tutorial](https://vdm.bz/how-to-install-jcb-packages).
Where can you get support and help?
====================
+ [The JCB Tutorials](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE)
+ [German Basic Introduction](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wu0tDFxJtZFwW7AxA4JHQV7)
+ [Hello World Tutorial](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
+ [The JCB! Wiki](https://git.vdm.dev/joomla/Component-Builder/wiki)
+ [Forum](https://vdm.bz/jcb-forum)
+ [Report a Security Issue](https://www.joomlacomponentbuilder.com/report-security-issues)
+ [Community Complaint](https://www.joomlacomponentbuilder.com/community-complaint)
+ [Open Issue On Gitea](https://git.vdm.dev/joomla/Component-Builder/issues) ^^
Since [JCB](https://www.joomlacomponentbuilder.com) has [become a community](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/SUPPORT.md) project [VDM.io](https://www.vdm.io/) is **no longer solely responsible** for support.
We have started a [**JCB forum**](https://vdm.bz/jcb-forum) where you can post questions, about how things work, or if you need some kind of help in relation to your development of your components.
^^ Then if you run into any issues, related to the [JCB](https://git.vdm.dev/joomla/Component-Builder/issues) code, like bugs, **start by searching** the (*open & closed*) issues over on [Gitea](https://git.vdm.dev/joomla/Component-Builder/issues), and if the issue has not been mentioned before, **then only** open a new issue, following the [community guidelines](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/CONTRIBUTING.md).
WHY GIVE IT AWAY LIKE THIS?
====================
> We are Open Source Enthusiast
> Who Support the [Joomla](https://extensions.joomla.org/extension/component-builder/) Community
Our idea was to almost let this tool serve as a cheat sheet to how things can be done... and with the help of other developers end up formulating the way how things not only can, but must be done to insure secure, stable, scalable and maintainable code is produced.
MAKING IT BETTER!
====================
Get involved on the forums, and the Gitea issues, and you can even help us develop/improve the pipeline of [JCB](https://www.joomlacomponentbuilder.com) for continues delivery. We really want to see [JCB](https://www.joomlacomponentbuilder.com) remain the tool of choice for all [Joomla Component Development](https://extensions.joomla.org/extension/component-builder/) needs and ideas.
TODO
======
- Add automatic unit testing. To nurture pipeline integration for all components build with [JCB](https://www.joomlacomponentbuilder.com).
- Team collaborative development across [JCB](https://www.joomlacomponentbuilder.com) installations offline and online.
- Documentation (maintained by the community) for [JCB](https://www.joomlacomponentbuilder.com). (help us select the best system for this)
# Build Details
+ *Community*: [Vast Development Method](https://dev.vdm.io)
+ *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*: 13th November, 2022
+ *Version*: 3.1.12
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **334311**
+ *Field count*: **2004**
+ *File count*: **2183**
+ *Folder count*: **381**
> 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:llewellyn@joomlacomponentbuilder.com)
# Joomla Component Builder ([JCB](https://www.joomlacomponentbuilder.com))
## Contributors
This project exists thanks to all the people who contribute to the [Joomla Component Builder Project](https://github.com/vdm-io/Joomla-Component-Builder).
[![Contributors](https://opencollective.com/Joomla-Component-Builder/contributors.svg?width=890&button=false)](https://github.com/vdm-io/Joomla-Component-Builder/graphs/contributors)
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/Joomla-Component-Builder#backer)]
[![Our Backers on opencollective](https://opencollective.com/Joomla-Component-Builder/backers.svg?width=890)](https://opencollective.com/Joomla-Component-Builder#backers)
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/Joomla-Component-Builder#sponsor)]
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/0/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/0/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/1/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/1/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/2/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/2/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/3/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/3/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/4/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/4/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/5/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/5/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/6/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/6/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/7/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/7/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/8/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/8/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/9/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/9/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/10/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/10/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/11/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/11/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/12/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/12/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/13/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/13/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/14/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/14/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/15/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/15/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/16/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/16/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/17/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/17/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/18/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/18/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/19/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/19/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/20/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/20/website)
This is a [Joomla 3.x](https://extensions.joomla.org/extension/component-builder/) component. [__See In Action__](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
![Component Builder image](https://git.vdm.dev/joomla/Component-Builder/raw/branch/master/admin/assets/images/jcb-banner.jpg "The Component Builder")
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!
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.13) 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)
Once installed upgrades are quick and easy via the default [Joomla](https://extensions.joomla.org/extension/component-builder/) upgrade area.
Some of the Features
====================
+ Fetch Code from IDE and place it back in component during next compilation.
+ Add [Joomla custom fields](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=75) in any of your components.
+ Add you [own dashboard](https://www.youtube.com/watch?v=tU7TeYn1Djo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=60) in the back-end.
+ [Dynamic File and Folder](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=56) Inclusion concept.
+ [Easy Translation](https://www.youtube.com/watch?v=q5NwKGnOHoQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=51) via excel.
+ Adding your [own rule validation](https://www.youtube.com/watch?v=Z6-ggKtX35o&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=46) to a field in [JCB](https://www.joomlacomponentbuilder.com)
+ [Automated backup system](https://www.youtube.com/watch?v=GUWZaODo_IM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=0s&index=40) in [JCB](https://www.joomlacomponentbuilder.com).
+ Adding mySQL Dump to any View/Table.
+ Grab existing Table data and build a dynamic dump.
+ Unlimited [Joomla](https://extensions.joomla.org/extension/component-builder/) Components.
+ Unlimited Tables/Views.
+ Reusing Views and Fields.
+ Runs on Your Own [Joomla](https://extensions.joomla.org/extension/component-builder/) Install.
+ Add Dynamic/custom back-end views that uses Table and Chart result sets.
+ Build data query of extreme complex nature to use in Dynamic/custom views.
+ Highly Dynamic/custom Front-end Structures.
+ Dynamically setup templates and layouts for Front-end design.
+ Integration of the excellent UIKIT lib.
+ Integration of the excellent FOOTABLE lib.
+ All [Joomla](https://extensions.joomla.org/extension/component-builder/) Standard Field Types (including subforms).
+ Strong Implementation of all [Joomla](https://extensions.joomla.org/extension/component-builder/) Form Security.
+ Load data via ajax with ease.
+ You can add an Update Server to Components you build.
+ Build advanced Dynamic front-end forms.
+ Dynamic data queries from multiple tables.
+ Place in local GIT folder, and publish to sales server.
+ Include any amount of custom files and folders during build.
+ Static helper class with smart methods already included.
+ Static helper methods Can easily be added.
+ Direct install from compiler view.
+ Integrative with native [Joomla](https://extensions.joomla.org/extension/component-builder/) Categories and Tags.
+ Fully Dynamic Search Friendly URL Auto Implementation.
+ Custom scripting options all over the MVC structure.
+ Permission implementation down to each view, item and field.
+ Easy extendible to include other libraries.
+ Can include SQL and visioning update link to distribute your component updates via [Joomla](https://extensions.joomla.org/extension/component-builder/) default upgrade of components.
+ Easy Export & Import addon to all backend-tables.
+ Overriding ability of import concepts in all backend-tables.
+ The Batch and Filter implementation on all backend-list views.
+ This and much much more are all possible with this component builder!
Just Imagine
====================
+ Your Component Back-end can be more advanced then the [Joomla](https://extensions.joomla.org/extension/component-builder/) Article Manager.
+ Your Code as Perfectly Unified to the strict [Joomla](https://extensions.joomla.org/extension/component-builder/) Standards.
+ Adding Custom Scripting almost anywhere in the MVC structure.
+ Import and export feature to all backend-views.
+ Batch copy and move/update feature for all backend-views.
+ History tracking per/change made on any back-end item.
+ Dynamic field control, to show and hide fields in amazing ways.
+ Front-end freedom of design that allows for any library to be used.
+ This and much much more are all possible with this component builder!
You are in Control
====================
+ You can change the licensing template for your components.
+ You can change/improve existing field types and add more.
+ Line numbers to show where in compiler was the code build.
+ You can improve the component since all code are open-source.
+ Free updates for the lifetime of the project.
+ You can dynamically add internal help structures to all component.
+ There is no limitations on how big or how much you want to build (server limitation only).
+ This is a complete factory kind of component that functions like a deployment hub.
+ Export any component completely mapped in [JCB](https://www.joomlacomponentbuilder.com) and import into another [JCB](https://www.joomlacomponentbuilder.com).
+ This and much much more are all possible with this component builder!
Get More Demo Content
====================
> You can now get access to the WOW factor, [JCB](https://www.joomlacomponentbuilder.com) fully mapped can now be yours! Including many other [JCB](https://www.joomlacomponentbuilder.com) mapped components.
### All you need to do is [explained here](https://vdm.bz/how-to-get-free-vdm-package-keys)!
To install these packages [watch this tutorial](https://vdm.bz/how-to-install-jcb-packages).
Where can you get support and help?
====================
+ [The JCB Tutorials](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE)
+ [German Basic Introduction](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wu0tDFxJtZFwW7AxA4JHQV7)
+ [Hello World Tutorial](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
+ [The JCB! Wiki](https://git.vdm.dev/joomla/Component-Builder/wiki)
+ [Forum](https://vdm.bz/jcb-forum)
+ [Report a Security Issue](https://www.joomlacomponentbuilder.com/report-security-issues)
+ [Community Complaint](https://www.joomlacomponentbuilder.com/community-complaint)
+ [Open Issue On Gitea](https://git.vdm.dev/joomla/Component-Builder/issues) ^^
Since [JCB](https://www.joomlacomponentbuilder.com) has [become a community](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/SUPPORT.md) project [VDM.io](https://www.vdm.io/) is **no longer solely responsible** for support.
We have started a [**JCB forum**](https://vdm.bz/jcb-forum) where you can post questions, about how things work, or if you need some kind of help in relation to your development of your components.
^^ Then if you run into any issues, related to the [JCB](https://git.vdm.dev/joomla/Component-Builder/issues) code, like bugs, **start by searching** the (*open & closed*) issues over on [Gitea](https://git.vdm.dev/joomla/Component-Builder/issues), and if the issue has not been mentioned before, **then only** open a new issue, following the [community guidelines](https://git.vdm.dev/joomla/Component-Builder/src/branch/master/.github/CONTRIBUTING.md).
WHY GIVE IT AWAY LIKE THIS?
====================
> We are Open Source Enthusiast
> Who Support the [Joomla](https://extensions.joomla.org/extension/component-builder/) Community
Our idea was to almost let this tool serve as a cheat sheet to how things can be done... and with the help of other developers end up formulating the way how things not only can, but must be done to insure secure, stable, scalable and maintainable code is produced.
MAKING IT BETTER!
====================
Get involved on the forums, and the Gitea issues, and you can even help us develop/improve the pipeline of [JCB](https://www.joomlacomponentbuilder.com) for continues delivery. We really want to see [JCB](https://www.joomlacomponentbuilder.com) remain the tool of choice for all [Joomla Component Development](https://extensions.joomla.org/extension/component-builder/) needs and ideas.
TODO
======
- Add automatic unit testing. To nurture pipeline integration for all components build with [JCB](https://www.joomlacomponentbuilder.com).
- Team collaborative development across [JCB](https://www.joomlacomponentbuilder.com) installations offline and online.
- Documentation (maintained by the community) for [JCB](https://www.joomlacomponentbuilder.com). (help us select the best system for this)
# Build Details
+ *Community*: [Vast Development Method](https://dev.vdm.io)
+ *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*: 29th January, 2023
+ *Version*: 3.1.13
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **360674**
+ *Field count*: **2009**
+ *File count*: **2314**
+ *Folder count*: **408**
> 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:llewellyn@joomlacomponentbuilder.com)
## Contributors
This project exists thanks to all the people who contribute to the [Joomla Component Builder Project](https://github.com/vdm-io/Joomla-Component-Builder).
[![Contributors](https://opencollective.com/Joomla-Component-Builder/contributors.svg?width=890&button=false)](https://github.com/vdm-io/Joomla-Component-Builder/graphs/contributors)
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/Joomla-Component-Builder#backer)]
[![Our Backers on opencollective](https://opencollective.com/Joomla-Component-Builder/backers.svg?width=890)](https://opencollective.com/Joomla-Component-Builder#backers)
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/Joomla-Component-Builder#sponsor)]
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/0/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/0/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/1/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/1/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/2/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/2/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/3/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/3/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/4/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/4/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/5/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/5/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/6/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/6/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/7/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/7/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/8/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/8/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/9/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/9/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/10/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/10/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/11/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/11/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/12/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/12/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/13/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/13/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/14/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/14/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/15/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/15/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/16/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/16/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/17/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/17/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/18/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/18/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/19/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/19/website)
[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/20/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/20/website)

View File

@ -191,14 +191,14 @@ const getSelectedItem = async (table, row, field, line) => {
formData.append('regex_search', regexObject.checked ? 1 : 0);
// get search value
if (mode == 1) {
// calling URL
postURL = UrlAjax + 'getSearchValue';
} else {
if (mode == 2) {
// add the line value
formData.append('line_nr', line);
// calling URL
postURL = UrlAjax + 'getReplaceValue';
} else {
// calling URL
postURL = UrlAjax + 'getSearchValue';
}
let options = {
@ -613,6 +613,16 @@ const buttonUpdateAllStyleDisplay = async (value) => {
* JS Function to execute (A) on search/replace text change , (B) on search options changes
*/
const startSearch = (field, forced = false) => {
// check mode
let mode = modeObject.querySelector('input[type=\'radio\']:checked').value;
if (mode == 0) {
// reset the search area
window.location.href = UrlSearch;
}
// check if we have an Enter click
if (field && typeof field.code !== 'undefined' && field.code === "Enter") {
forced = true;
}
// get replace value if set
const replaceValue = replaceObject.value;
if (replaceValue.length > 0) {

View File

@ -171,19 +171,19 @@ class ComponentbuilderControllerCompiler extends AdminController
}
$message[] = '<h2>Total time saved</h2>';
$message[] = '<ul>';
$message[] = '<li>Total folders created: <b>'.$model->compiler->folderCount.'</b></li>';
$message[] = '<li>Total files created: <b>'.$model->compiler->fileCount.'</b></li>';
$message[] = '<li>Total fields created: <b>'.$model->compiler->fieldCount.'</b></li>';
$message[] = '<li>Total lines written: <b>'.$model->compiler->lineCount.'</b></li>';
$message[] = '<li>A4 Book of: <b>'.$model->compiler->pageCount.' pages</b></li>';
$message[] = '<li>Total folders created: <b>#'.'##FOLDER_COUNT##'.'#</b></li>';
$message[] = '<li>Total files created: <b>#'.'##FILE_COUNT##'.'#</b></li>';
$message[] = '<li>Total fields created: <b>#'.'##FIELD_COUNT##'.'#</b></li>';
$message[] = '<li>Total lines written: <b>#'.'##LINE_COUNT##'.'#</b></li>';
$message[] = '<li>A4 Book of: <b>#'.'##PAGE_COUNT##'.'# pages</b></li>';
$message[] = '</ul>';
$message[] = '<p><b>'.$model->compiler->totalHours.' Hours</b> or <b>'.$model->compiler->totalDays.' Eight Hour Days</b> <em>(actual time you saved)</em><br />';
$message[] = '<p><b>#'.'##totalHours##'.'# Hours</b> or <b>#'.'##totalDays##'.'# Eight Hour Days</b> <em>(actual time you saved)</em><br />';
$message[] = '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, never making one mistake or taking any coffee break.)</small><br />';
$message[] = '<b>'.$model->compiler->actualHoursSpent.' Hours</b> or <b>'.$model->compiler->actualDaysSpent.' Eight Hour Days</b> <em>(the actual time you spent)</em><br />';
$message[] = '<small>(with the following break down: <b>debugging @'.$model->compiler->debuggingHours.'hours</b> = codingtime / 4; <b>planning @'.$model->compiler->planningHours.'hours</b> = codingtime / 7; <b>mapping @'.$model->compiler->mappingHours.'hours</b> = codingtime / 10; <b>office @'.$model->compiler->officeHours.'hours</b> = codingtime / 6;)</small></p>';
$message[] = '<p><b>'.$model->compiler->actualTotalHours.' Hours</b> or <b>'.$model->compiler->actualTotalDays.' Eight Hour Days</b> <em>(a total of the realistic time frame for this project)</em><br />';
$message[] = '<b>#'.'##actualHoursSpent##'.'# Hours</b> or <b>#'.'##actualDaysSpent##'.'# Eight Hour Days</b> <em>(the actual time you spent)</em><br />';
$message[] = '<small>(with the following break down: <b>debugging @#'.'##debuggingHours##'.'#hours</b> = codingtime / 4; <b>planning @#'.'##planningHours##'.'#hours</b> = codingtime / 7; <b>mapping @#'.'##mappingHours##'.'#hours</b> = codingtime / 10; <b>office @#'.'##officeHours##'.'#hours</b> = codingtime / 6;)</small></p>';
$message[] = '<p><b>#'.'##actualTotalHours##'.'# Hours</b> or <b>#'.'##actualTotalDays##'.'# Eight Hour Days</b> <em>(a total of the realistic time frame for this project)</em><br />';
$message[] = '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)</small></p>';
$message[] = '<p>Project duration: <b>'.$model->compiler->projectWeekTime. ' weeks</b> or <b>'.$model->compiler->projectMonthTime.' months</b></p>';
$message[] = '<p>Project duration: <b>'.$model->compiler->projectWeekTime. ' weeks</b> or <b>#'.'##projectMonthTime##'.'# months</b></p>';
// check if we have modules or plugins
if ($add_multi_install)
{
@ -254,9 +254,14 @@ class ComponentbuilderControllerCompiler extends AdminController
$message[] = '<a class="btn btn-success" href="' . $url . '" ><span class="icon-download icon-white"></span>Download</a></p>';
$message[] = '<p><small><b>Remember!</b> This zip file is in your tmp folder and therefore publicly accessible until you click [Clear tmp]!</small> </p>';
}
$message[] = '<p><small>Compilation took <b>'.$model->compiler->secondsCompiled.'</b> seconds to complete.</small> </p>';
$message[] = '<p><small>Compilation took <b>#'.'##COMPILER_TIMER##'.'#</b> seconds to complete.</small> </p>';
// pass the message via the user state... wow this is painful
$app->setUserState('com_componentbuilder.success_message', implode(PHP_EOL, $message));
$app->setUserState('com_componentbuilder.success_message',
CFactory::_('Placeholder')->update(
implode(PHP_EOL, $message),
CFactory::_('Content')->active
)
);
// set redirect
$this->setRedirect($redirect_url, '<h2>Successful Build!</h2>', 'message');
$app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']);

View File

@ -19,6 +19,7 @@ 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;
@ -30,11 +31,11 @@ ComponentbuilderHelper::autoLoader();
/**
* Compiler class
* @deprecated 3.3
*/
class Compiler extends Infusion
{
/**
* The Temp path
*
@ -79,7 +80,8 @@ class Compiler extends Infusion
{
// to check the compiler speed
$this->time_start = microtime(true);
// first we run the perent constructors
CFactory::_('Utilities.Counter')->start();
// first we run the parent constructors
if (parent::__construct())
{
// set temp directory
@ -99,33 +101,33 @@ class Compiler extends Infusion
$this->repoPath = $this->params->get('git_folder_path', null);
}
// 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 ($this->removeSiteFolder && $this->removeSiteEditFolder)
if (CFactory::_('Config')->remove_site_folder && CFactory::_('Config')->remove_site_edit_folder)
{
// first remove the files and folders
$this->removeFolder($this->componentPath . '/site');
CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path . '/site');
// clear form component xml
$xmlPath = $this->componentPath . '/'
. $this->fileContentStatic[Placefix::_h('component')] . '.xml';
$componentXML = ComponentbuilderHelper::getFileContents(
$xmlPath
);
$textToSite = ComponentbuilderHelper::getBetween(
$xmlPath = CFactory::_('Utilities.Paths')->component_path . '/'
. CFactory::_('Content')->get('component') . '.xml';
$componentXML = FileHelper::getContent($xmlPath);
$textToSite = GetHelper::between(
$componentXML, '<files folder="site">', '</files>'
);
$textToSiteLang = ComponentbuilderHelper::getBetween(
$textToSiteLang = GetHelper::between(
$componentXML, '<languages folder="site">', '</languages>'
);
$componentXML = str_replace(
array('<files folder="site">' . $textToSite . "</files>",
'<languages folder="site">' . $textToSiteLang
. "</languages>"), array('', ''), $componentXML
. "</languages>"), array('', ''), (string) $componentXML
);
$this->writeFile($xmlPath, $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(&$this->componentContext, &$this)
array(&$component_context, &$this)
);
// now update the files
if (!$this->updateFiles())
@ -135,7 +137,7 @@ class Compiler extends Infusion
// Trigger Event: jcb_ce_onBeforeGetCustomCode
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeGetCustomCode',
array(&$this->componentContext, &$this)
array(&$component_context, &$this)
);
// now insert into the new files
if (CFactory::_('Customcode')->get())
@ -143,7 +145,7 @@ class Compiler extends Infusion
// Trigger Event: jcb_ce_onBeforeAddCustomCode
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeAddCustomCode',
array(&$this->componentContext, &$this)
array(&$component_context, &$this)
);
$this->addCustomCode();
@ -151,7 +153,7 @@ class Compiler extends Infusion
// Trigger Event: jcb_ce_onBeforeSetLangFileData
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeSetLangFileData',
array(&$this->componentContext, &$this)
array(&$component_context, &$this)
);
// set the lang data now
$this->setLangFileData();
@ -218,13 +220,15 @@ class Compiler extends Infusion
$message_fix['sql'] = JText::_(
'The <b>SQL</b> 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 (CFactory::_('Config')->add_assets_table_fix)
if ($add_assets_table_fix)
{
$this->app->enqueueMessage(
JText::_('<hr /><h3>Assets Table Notice</h3>'), 'Notice'
);
$asset_table_fix_type = (CFactory::_('Config')->add_assets_table_fix == 2)
$asset_table_fix_type = ($add_assets_table_fix == 2)
? 'intelligent' : 'sql';
$this->app->enqueueMessage(
JText::sprintf(
@ -243,13 +247,13 @@ class Compiler extends Infusion
$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 <b>%s</b> characters, and yet the Joomla default is only <b>varchar(5120)</b>. JCB has three option to resolve this issue, first <b>use less permissions</b> in your component, second use the <b>SQL</b> fix, or the <b>intelligent</b> fix. %s %s',
$this->accessWorseCase, $message_fix['intelligent'],
CFactory::_('Config')->access_worse_case, $message_fix['intelligent'],
$message_fix['sql']
), 'Warning'
);
}
// set assets table name column warning if not set
if (!CFactory::_('Config')->add_assets_table_fix && $this->addAssetsTableNameFix)
if (!$add_assets_table_fix && CFactory::_('Config')->add_assets_table_name_fix)
{
// only add if not already added
if ($this->accessSize < 30)
@ -269,8 +273,6 @@ class Compiler extends Infusion
}
// move the update server into place
$this->setUpdateServer();
// set the global counters
$this->setCountingStuff();
// build read me
$this->buildReadMe();
// set local repos
@ -361,6 +363,7 @@ class Compiler extends Infusion
// 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;
@ -377,15 +380,13 @@ class Compiler extends Infusion
*/
protected function updateFiles()
{
if (isset($this->newFiles['static'])
&& ArrayHelper::check($this->newFiles['static'])
&& isset($this->newFiles['dynamic'])
&& ArrayHelper::check($this->newFiles['dynamic']))
if (CFactory::_('Utilities.Files')->exists('static')
&& CFactory::_('Utilities.Files')->exists('dynamic'))
{
// get the bom file
$bom = ComponentbuilderHelper::getFileContents($this->bomPath);
$bom = FileHelper::getContent(CFactory::_('Config')->bom_path);
// first we do the static files
foreach ($this->newFiles['static'] as $static)
foreach (CFactory::_('Utilities.Files')->get('static') as $static)
{
if (File::exists($static['path']))
{
@ -395,11 +396,11 @@ class Compiler extends Infusion
}
}
// now we do the dynamic files
foreach ($this->newFiles['dynamic'] as $view => $files)
foreach (CFactory::_('Utilities.Files')->get('dynamic') as $view => $files)
{
if (isset($this->fileContentDynamic[$view])
if (CFactory::_('Content')->exist_($view)
&& ArrayHelper::check(
$this->fileContentDynamic[$view]
CFactory::_('Content')->get_($view)
))
{
foreach ($files as $file)
@ -417,20 +418,17 @@ class Compiler extends Infusion
}
}
// free up some memory
unset($this->fileContentDynamic[$view]);
CFactory::_('Content')->remove_($view);
}
// free up some memory
unset($this->newFiles['dynamic']);
CFactory::_('Utilities.Files')->remove('dynamic');
// do modules if found
if (ArrayHelper::check($this->joomlaModules))
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach ($this->joomlaModules as $module)
foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{
if (ObjectHelper::check($module)
&& isset($this->newFiles[$module->key])
&& ArrayHelper::check(
$this->newFiles[$module->key]
))
&& CFactory::_('Utilities.Files')->exists($module->key))
{
// move field or rule if needed
if (isset($module->fields_rules_paths)
@ -486,7 +484,7 @@ class Compiler extends Infusion
}
}
// update the module files
foreach ($this->newFiles[$module->key] as $module_file)
foreach (CFactory::_('Utilities.Files')->get($module->key) as $module_file)
{
if (File::exists($module_file['path']))
{
@ -497,21 +495,18 @@ class Compiler extends Infusion
}
}
// free up some memory
unset($this->newFiles[$module->key]);
unset($this->fileContentDynamic[$module->key]);
CFactory::_('Utilities.Files')->remove($module->key);
CFactory::_('Content')->remove_($module->key);
}
}
}
// do plugins if found
if (ArrayHelper::check($this->joomlaPlugins))
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach ($this->joomlaPlugins as $plugin)
foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($this->newFiles[$plugin->key])
&& ArrayHelper::check(
$this->newFiles[$plugin->key]
))
&& CFactory::_('Utilities.Files')->exists($plugin->key))
{
// move field or rule if needed
if (isset($plugin->fields_rules_paths)
@ -567,7 +562,7 @@ class Compiler extends Infusion
}
}
// update the plugin files
foreach ($this->newFiles[$plugin->key] as $plugin_file)
foreach (CFactory::_('Utilities.Files')->get($plugin->key) as $plugin_file)
{
if (File::exists($plugin_file['path']))
{
@ -578,8 +573,8 @@ class Compiler extends Infusion
}
}
// free up some memory
unset($this->newFiles[$plugin->key]);
unset($this->fileContentDynamic[$plugin->key]);
CFactory::_('Utilities.Files')->remove($plugin->key);
CFactory::_('Content')->remove_($plugin->key);
}
}
}
@ -589,13 +584,10 @@ class Compiler extends Infusion
foreach (CFactory::_('Power')->active as $power)
{
if (ObjectHelper::check($power)
&& isset($this->newFiles[$power->key])
&& ArrayHelper::check(
$this->newFiles[$power->key]
))
&& CFactory::_('Utilities.Files')->exists($power->key))
{
// update the power files
foreach ($this->newFiles[$power->key] as $power_file)
foreach (CFactory::_('Utilities.Files')->get($power->key) as $power_file)
{
if (File::exists($power_file['path']))
{
@ -606,8 +598,8 @@ class Compiler extends Infusion
}
}
// free up some memory
unset($this->newFiles[$power->key]);
unset($this->fileContentDynamic[$power->key]);
CFactory::_('Utilities.Files')->remove($power->key);
CFactory::_('Content')->remove_($power->key);
}
}
}
@ -626,13 +618,15 @@ class Compiler extends Infusion
*/
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(&$this->componentContext, &$name, &$path, &$bom, &$view)
array(&$component_context, &$name, &$path, &$bom, &$view)
);
// set the file name
$this->fileContentStatic[Placefix::_h('FILENAME')] = $name;
CFactory::_('Content')->set('FILENAME', $name);
// check if the file should get PHP opening
$php = '';
if (ComponentbuilderHelper::checkFileType($name, 'php'))
@ -640,28 +634,28 @@ class Compiler extends Infusion
$php = "<?php\n";
}
// get content of the file
$string = ComponentbuilderHelper::getFileContents($path);
$string = FileHelper::getContent($path);
// Trigger Event: jcb_ce_onGetFileContents
CFactory::_('Event')->trigger(
'jcb_ce_onGetFileContents',
array(&$this->componentContext, &$string, &$name, &$path, &$bom,
array(&$component_context, &$string, &$name, &$path, &$bom,
&$view)
);
// see if we should add a BOM
if (strpos($string, Placefix::_h('BOM')) !== false)
if (strpos((string) $string, (string) Placefix::_h('BOM')) !== false)
{
list($wast, $code) = explode(
Placefix::_h('BOM'), $string
Placefix::_h('BOM'), (string) $string
);
$string = $php . $bom . $code;
}
// set the answer
$answer = CFactory::_('Placeholder')->update($string, $this->fileContentStatic, 3);
$answer = CFactory::_('Placeholder')->update($string, CFactory::_('Content')->active, 3);
// set the dynamic answer
if ($view)
{
$answer = CFactory::_('Placeholder')->update(
$answer, $this->fileContentDynamic[$view], 3
$answer, CFactory::_('Content')->get_($view), 3
);
}
// check if this file needs extra care :)
@ -672,13 +666,13 @@ class Compiler extends Infusion
// Trigger Event: jcb_ce_onBeforeSetFileContent
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeWriteFileContent',
array(&$this->componentContext, &$answer, &$name, &$path, &$bom,
array(&$component_context, &$answer, &$name, &$path, &$bom,
&$view)
);
// add answer back to file
$this->writeFile($path, $answer);
CFactory::_('Utilities.File')->write($path, $answer);
// count the file lines
$this->lineCount = $this->lineCount + substr_count($answer, PHP_EOL);
CFactory::_('Utilities.Counter')->line += substr_count((string) $answer, PHP_EOL);
}
/**
@ -690,32 +684,31 @@ class Compiler extends Infusion
protected function setUpdateServer()
{
// move the component update server to host
if ($this->componentData->add_update_server == 1
&& $this->componentData->update_server_target == 1
if (CFactory::_('Component')->get('add_update_server', 0) == 1
&& isset($this->updateServerFileName)
&& $this->dynamicIntegration)
{
$update_server_xml_path = $this->componentPath . '/'
$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)
&& isset($this->componentData->update_server))
&& ($update_server = CFactory::_('Component')->get('update_server')) !== null)
{
// move to server
ComponentbuilderHelper::moveToServer(
$update_server_xml_path,
$this->updateServerFileName . '.xml',
(int) $this->componentData->update_server,
$this->componentData->update_server_protocol
(int) $update_server,
CFactory::_('Component')->get('update_server_protocol')
);
// remove the local file
File::delete($update_server_xml_path);
}
}
// move the modules update server to host
if (ArrayHelper::check($this->joomlaModules))
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach ($this->joomlaModules as $module)
foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{
if (ObjectHelper::check($module)
&& isset($module->add_update_server)
@ -746,9 +739,9 @@ class Compiler extends Infusion
}
}
// move the plugins update server to host
if (ArrayHelper::check($this->joomlaPlugins))
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach ($this->joomlaPlugins as $plugin)
foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->add_update_server)
@ -787,7 +780,7 @@ class Compiler extends Infusion
&& ArrayHelper::check(
$data['config']
)
&& $this->componentData->mvc_versiondate == 1)
&& CFactory::_('Component')->get('mvc_versiondate', 0) == 1)
{
foreach ($data['config'] as $key => $value)
{
@ -805,68 +798,45 @@ class Compiler extends Infusion
$value = '@update number ' . $value . ' of this MVC';
}
}
$this->fileContentStatic[$key] = $value;
CFactory::_('Content')->set($key, $value);
}
return true;
}
// else insure to reset to global
$this->fileContentStatic[Placefix::_h('CREATIONDATE')]
= $this->fileContentStatic[Placefix::_h('CREATIONDATE')
. 'GLOBAL'];
$this->fileContentStatic[Placefix::_h('BUILDDATE')]
= $this->fileContentStatic[Placefix::_h('BUILDDATE')
. 'GLOBAL'];
$this->fileContentStatic[Placefix::_h('VERSION')]
= $this->fileContentStatic[Placefix::_h('VERSION')
. 'GLOBAL'];
CFactory::_('Content')->set('CREATIONDATE', CFactory::_('Content')->get('GLOBALCREATIONDATE'));
CFactory::_('Content')->set('BUILDDATE', CFactory::_('Content')->get('GLOBALBUILDDATE'));
CFactory::_('Content')->set('VERSION', CFactory::_('Content')->get('GLOBALVERSION'));
}
// set all global numbers
/**
* Set all global numbers
*
* @return void
* @deprecated 3.3
*/
protected function setCountingStuff()
{
// what is the size in terms of an A4 book
$this->pageCount = round($this->lineCount / 56);
// setup the unrealistic numbers
$this->folderSeconds = $this->folderCount * 5;
$this->fileSeconds = $this->fileCount * 5;
$this->lineSeconds = $this->lineCount * 10;
$this->seconds = $this->folderSeconds + $this->fileSeconds
+ $this->lineSeconds;
$this->totalHours = round($this->seconds / 3600);
$this->totalDays = round($this->totalHours / 8);
// setup the more realistic numbers
$this->secondsDebugging = $this->seconds / 4;
$this->secondsPlanning = $this->seconds / 7;
$this->secondsMapping = $this->seconds / 10;
$this->secondsOffice = $this->seconds / 6;
$this->actualSeconds = $this->folderSeconds + $this->fileSeconds
+ $this->lineSeconds + $this->secondsDebugging
+ $this->secondsPlanning + $this->secondsMapping
+ $this->secondsOffice;
$this->actualTotalHours = round($this->actualSeconds / 3600);
$this->actualTotalDays = round($this->actualTotalHours / 8);
$this->debuggingHours = round($this->secondsDebugging / 3600);
$this->planningHours = round($this->secondsPlanning / 3600);
$this->mappingHours = round($this->secondsMapping / 3600);
$this->officeHours = round($this->secondsOffice / 3600);
// the actual time spent
$this->actualHoursSpent = $this->actualTotalHours - $this->totalHours;
$this->actualDaysSpent = $this->actualTotalDays - $this->totalDays;
// calculate the projects actual time frame of completion
$this->projectWeekTime = round($this->actualTotalDays / 5, 1);
$this->projectMonthTime = round($this->actualTotalDays / 24, 1);
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
JText::sprintf('<hr /><h3>%s Warning</h3>', __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;
foreach ($this->newFiles['static'] as $static)
foreach (CFactory::_('Utilities.Files')->get('static') as $static)
{
if (('README.md' === $static['name']
|| 'README.txt' === $static['name'])
&& $this->componentData->addreadme
&& CFactory::_('Component')->get('addreadme')
&& File::exists($static['path']))
{
$this->setReadMe($static['path']);
@ -877,97 +847,42 @@ class Compiler extends Infusion
break;
}
}
unset($this->newFiles['static']);
CFactory::_('Utilities.Files')->remove('static');
}
private function setReadMe($path)
{
// set readme data if not set already
if (!isset(
$this->fileContentStatic[Placefix::_h('LINE_COUNT')]
)
|| $this->fileContentStatic[Placefix::_h('LINE_COUNT')]
!= $this->lineCount)
if (!CFactory::_('Content')->exist('LINE_COUNT')
|| CFactory::_('Content')->get('LINE_COUNT') != CFactory::_('Utilities.Counter')->line)
{
$this->buildReadMeData();
CFactory::_('Utilities.Counter')->set();
}
// get the file
$string = ComponentbuilderHelper::getFileContents($path);
$string = FileHelper::getContent($path);
// update the file
$answer = CFactory::_('Placeholder')->update($string, $this->fileContentStatic);
$answer = CFactory::_('Placeholder')->update($string, CFactory::_('Content')->active);
// add to zip array
$this->writeFile($path, $answer);
CFactory::_('Utilities.File')->write($path, $answer);
}
/**
* Build README data
*
* @return void
* @deprecated 3.3
*/
private function buildReadMeData()
{
// set some defaults
$this->fileContentStatic[Placefix::_h('LINE_COUNT')]
= $this->lineCount;
$this->fileContentStatic[Placefix::_h('FIELD_COUNT')]
= $this->fieldCount;
$this->fileContentStatic[Placefix::_h('FILE_COUNT')]
= $this->fileCount;
$this->fileContentStatic[Placefix::_h('FOLDER_COUNT')]
= $this->folderCount;
$this->fileContentStatic[Placefix::_h('PAGE_COUNT')]
= $this->pageCount;
$this->fileContentStatic[Placefix::_h('folders')]
= $this->folderSeconds;
$this->fileContentStatic[Placefix::_h('foldersSeconds')]
= $this->folderSeconds;
$this->fileContentStatic[Placefix::_h('files')]
= $this->fileSeconds;
$this->fileContentStatic[Placefix::_h('filesSeconds')]
= $this->fileSeconds;
$this->fileContentStatic[Placefix::_h('lines')]
= $this->lineSeconds;
$this->fileContentStatic[Placefix::_h('linesSeconds')]
= $this->lineSeconds;
$this->fileContentStatic[Placefix::_h('seconds')]
= $this->actualSeconds;
$this->fileContentStatic[Placefix::_h('actualSeconds')]
= $this->actualSeconds;
$this->fileContentStatic[Placefix::_h('totalHours')]
= $this->totalHours;
$this->fileContentStatic[Placefix::_h('totalDays')]
= $this->totalDays;
$this->fileContentStatic[Placefix::_h('debugging')]
= $this->secondsDebugging;
$this->fileContentStatic[Placefix::_h('secondsDebugging')]
= $this->secondsDebugging;
$this->fileContentStatic[Placefix::_h('planning')]
= $this->secondsPlanning;
$this->fileContentStatic[Placefix::_h('secondsPlanning')]
= $this->secondsPlanning;
$this->fileContentStatic[Placefix::_h('mapping')]
= $this->secondsMapping;
$this->fileContentStatic[Placefix::_h('secondsMapping')]
= $this->secondsMapping;
$this->fileContentStatic[Placefix::_h('office')]
= $this->secondsOffice;
$this->fileContentStatic[Placefix::_h('secondsOffice')]
= $this->secondsOffice;
$this->fileContentStatic[Placefix::_h('actualTotalHours')]
= $this->actualTotalHours;
$this->fileContentStatic[Placefix::_h('actualTotalDays')]
= $this->actualTotalDays;
$this->fileContentStatic[Placefix::_h('debuggingHours')]
= $this->debuggingHours;
$this->fileContentStatic[Placefix::_h('planningHours')]
= $this->planningHours;
$this->fileContentStatic[Placefix::_h('mappingHours')]
= $this->mappingHours;
$this->fileContentStatic[Placefix::_h('officeHours')]
= $this->officeHours;
$this->fileContentStatic[Placefix::_h('actualHoursSpent')]
= $this->actualHoursSpent;
$this->fileContentStatic[Placefix::_h('actualDaysSpent')]
= $this->actualDaysSpent;
$this->fileContentStatic[Placefix::_h('projectWeekTime')]
= $this->projectWeekTime;
$this->fileContentStatic[Placefix::_h('projectMonthTime')]
= $this->projectMonthTime;
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
);
$this->app->enqueueMessage(
JText::sprintf(
'Use of a deprecated method (%s)!', __METHOD__
), 'Error'
);
}
private function setLocalRepos()
@ -980,29 +895,32 @@ class Compiler extends Infusion
{
// set the repo path
$repoFullPath = $this->repoPath . '/com_'
. $this->componentData->sales_name . '__joomla_'
. 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(&$this->componentContext, &$this->componentPath,
array(&$component_context, &$component_path,
&$repoFullPath, &$this->componentData)
);
// remove old data
$this->removeFolder($repoFullPath, $this->componentData->toignore);
CFactory::_('Utilities.Folder')->remove($repoFullPath, CFactory::_('Component')->get('toignore'));
// set the new data
Folder::copy($this->componentPath, $repoFullPath, '', true);
Folder::copy(CFactory::_('Utilities.Paths')->component_path, $repoFullPath, '', true);
// Trigger Event: jcb_ce_onAfterUpdateRepo
CFactory::_('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$this->componentContext, &$this->componentPath,
array(&$component_context, &$component_path,
&$repoFullPath, &$this->componentData)
);
// move the modules to local folder repos
if (ArrayHelper::check($this->joomlaModules))
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach ($this->joomlaModules as $module)
foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{
if (ObjectHelper::check($module)
&& isset($module->file_name))
@ -1020,8 +938,8 @@ class Compiler extends Infusion
&$repoFullPath, &$module)
);
// remove old data
$this->removeFolder(
$repoFullPath, $this->componentData->toignore
CFactory::_('Utilities.Folder')->remove(
$repoFullPath, CFactory::_('Component')->get('toignore')
);
// set the new data
Folder::copy(
@ -1037,9 +955,9 @@ class Compiler extends Infusion
}
}
// move the plugins to local folder repos
if (ArrayHelper::check($this->joomlaPlugins))
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach ($this->joomlaPlugins as $plugin)
foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->file_name))
@ -1057,8 +975,8 @@ class Compiler extends Infusion
&$repoFullPath, &$plugin)
);
// remove old data
$this->removeFolder(
$repoFullPath, $this->componentData->toignore
CFactory::_('Utilities.Folder')->remove(
$repoFullPath, CFactory::_('Component')->get('toignore')
);
// set the new data
Folder::copy(
@ -1079,20 +997,25 @@ class Compiler extends Infusion
private function zipComponent()
{
// Component Folder Name
$this->filepath['component-folder'] = $this->componentFolderName;
$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(&$this->componentContext, &$this->componentPath,
array(&$component_context, &$component_path,
&$this->filepath['component'], &$this->tempPath,
&$this->componentFolderName, &$this->componentData)
&$component_folder_name, &$this->componentData)
);
//create the zip file
if (FileHelper::zip(
$this->componentPath, $this->filepath['component']
CFactory::_('Utilities.Paths')->component_path, $this->filepath['component']
))
{
// now move to backup if zip was made and backup is required
@ -1100,7 +1023,7 @@ class Compiler extends Infusion
{
// Trigger Event: jcb_ce_onBeforeBackupZip
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBackupZip', array(&$this->componentContext,
'jcb_ce_onBeforeBackupZip', array(&$component_context,
&$this->filepath['component'],
&$this->tempPath,
&$this->backupPath,
@ -1109,42 +1032,42 @@ class Compiler extends Infusion
// copy the zip to backup path
File::copy(
$this->filepath['component'],
$this->backupPath . '/' . $this->componentBackupName
$this->backupPath . '/' . CFactory::_('Utilities.Paths')->component_backup_name
. '.zip'
);
}
// move to sales server host
if ($this->componentData->add_sales_server == 1
if (CFactory::_('Component')->get('add_sales_server', 0) == 1
&& $this->dynamicIntegration)
{
// make sure we have the correct file
if (isset($this->componentData->sales_server))
if (CFactory::_('Component')->get('sales_server'))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
CFactory::_('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
array(&$this->componentContext,
array(&$component_context,
&$this->filepath['component'], &$this->tempPath,
&$this->componentSalesName, &$this->componentData)
&$component_sales_name, &$this->componentData)
);
// move to server
ComponentbuilderHelper::moveToServer(
$this->filepath['component'],
$this->componentSalesName . '.zip',
(int) $this->componentData->sales_server,
$this->componentData->sales_server_protocol
$component_sales_name . '.zip',
(int) CFactory::_('Component')->get('sales_server'),
CFactory::_('Component')->get('sales_server_protocol')
);
}
}
// Trigger Event: jcb_ce_onAfterZipComponent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterZipComponent',
array(&$this->componentContext, &$this->filepath['component'],
&$this->tempPath, &$this->componentFolderName,
array(&$component_context, &$this->filepath['component'],
&$this->tempPath, &$component_folder_name,
&$this->componentData)
);
// remove the component folder since we are done
if ($this->removeFolder($this->componentPath))
if (CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path))
{
return true;
}
@ -1155,9 +1078,9 @@ class Compiler extends Infusion
private function zipModules()
{
if (ArrayHelper::check($this->joomlaModules))
if (CFactory::_('Joomlamodule.Data')->exists())
{
foreach ($this->joomlaModules as $module)
foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{
if (ObjectHelper::check($module)
&& isset($module->zip_name)
@ -1240,7 +1163,7 @@ class Compiler extends Infusion
&$module)
);
// remove the module folder since we are done
$this->removeFolder($module->folder_path);
CFactory::_('Utilities.Folder')->remove($module->folder_path);
}
}
}
@ -1249,9 +1172,9 @@ class Compiler extends Infusion
private function zipPlugins()
{
if (ArrayHelper::check($this->joomlaPlugins))
if (CFactory::_('Joomlaplugin.Data')->exists())
{
foreach ($this->joomlaPlugins as $plugin)
foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->zip_name)
@ -1334,7 +1257,7 @@ class Compiler extends Infusion
&$plugin)
);
// remove the plugin folder since we are done
$this->removeFolder($plugin->folder_path);
CFactory::_('Utilities.Folder')->remove($plugin->folder_path);
}
}
}
@ -1358,7 +1281,7 @@ class Compiler extends Infusion
$target['hashtarget'][1]
))
{
$file = $this->componentPath . '/' . $target['path'];
$file = CFactory::_('Utilities.Paths')->component_path . '/' . $target['path'];
$size = (int) $target['hashtarget'][0];
$hash = $target['hashtarget'][1];
$cut = $size - 1;
@ -1462,8 +1385,8 @@ class Compiler extends Infusion
$target['id']
);
$data = $placeholder['start'] . PHP_EOL
. CFactory::_('Placeholder')->update(
$target['code'], CFactory::_('Placeholder')->active
. CFactory::_('Placeholder')->update_(
$target['code']
) . $placeholder['end'] . PHP_EOL;
if ($target['type'] == 2)
{
@ -1547,7 +1470,7 @@ class Compiler extends Infusion
$_commentType = " -->";
}
// escape the code
$code = explode(PHP_EOL, $target['code']);
$code = explode(PHP_EOL, (string) $target['code']);
$code = PHP_EOL . $commentType . implode(
$_commentType . PHP_EOL . $commentType, $code
) . $_commentType . PHP_EOL;
@ -1581,10 +1504,10 @@ class Compiler extends Infusion
// move to the position where we should add the data
fseek($fpFile, $position);
// Add the data
fwrite($fpFile, $data);
fwrite($fpFile, (string) $data);
// truncate file at the end of the data that was added
$remove = MathHelper::bc(
'add', $position, mb_strlen($data, '8bit')
'add', $position, mb_strlen((string) $data, '8bit')
);
ftruncate($fpFile, $remove);
// check if this was a replacement of data

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,13 +12,22 @@
// 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 = array(
$search = [
'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla',
'libraries/jcb_powers/VDM.Gitea' => 'VDM\\Gitea'
);
'libraries/jcb_powers/VDM.Minify' => 'VDM\\Minify',
'libraries/jcb_powers/VDM.Gitea' => 'VDM\\Gitea',
'libraries/jcb_powers/VDM.Psr' => 'VDM\\Psr'
];
// Start the search and load if found
$found = false;
$found_base_dir = "";
@ -40,7 +49,7 @@ spl_autoload_register(function ($class) {
// check if we found a match
if (!$found)
{
// no, move to the next registered autoloader
// not found so move to the next registered autoloader
return;
}
// get the relative class name
@ -1071,8 +1080,6 @@ abstract class ComponentbuilderHelper
{
// import the Joomla librarys
jimport('joomla.application.component.modellist');
// include class to minify js
require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/js.php';
}
// load only if smart
if ('smart' === $type)
@ -3813,31 +3820,31 @@ abstract class ComponentbuilderHelper
switch ($mode)
{
case 'CTR':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_CTR);
self::$CRYPT[$key] = new $CLASS('ctr');
break;
case 'ECB':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_ECB);
self::$CRYPT[$key] = new $CLASS('ecb');
break;
case 'CBC':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_CBC);
self::$CRYPT[$key] = new $CLASS('cbc');
break;
case 'CBC3':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_CBC3);
self::$CRYPT[$key] = new $CLASS('cbc3');
break;
case 'CFB':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_CFB);
self::$CRYPT[$key] = new $CLASS('cfb');
break;
case 'CFB8':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_CFB8);
self::$CRYPT[$key] = new $CLASS('cfb8');
break;
case 'OFB':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_OFB);
self::$CRYPT[$key] = new $CLASS('ofb');
break;
case 'GCM':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_GCM);
self::$CRYPT[$key] = new $CLASS('gcm');
break;
case 'STREAM':
self::$CRYPT[$key] = new $CLASS($CLASS::MODE_STREAM);
self::$CRYPT[$key] = new $CLASS('stream');
break;
default:
// No valid mode has been specified
@ -3848,7 +3855,7 @@ abstract class ComponentbuilderHelper
}
else
{
// set the
// set the default
self::$CRYPT[$key] = new $CLASS();
}
// return the object

View File

@ -26,6 +26,11 @@
// 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
*/
@ -102,7 +107,7 @@ class Mapping
// set the app to insure messages can be set
$this->app = JFactory::getApplication();
// check that we have data
if (ComponentbuilderHelper::checkArray($data))
if (ArrayHelper::check($data))
{
// make sure we have an id
if (isset($data['id']) && $data['id'] > 0)
@ -117,15 +122,15 @@ class Mapping
{
case 'base64':
// set needed value
$this->$key = base64_decode($value);
$this->$key = base64_decode((string) $value);
break;
case 'json':
// set needed value
$this->$key = json_decode($value, true);
$this->$key = json_decode((string) $value, true);
break;
case 'safeString':
// set needed value
$this->$key = ComponentbuilderHelper::safeString($value);
$this->$key = StringHelper::check($value);
break;
default :
$this->$key = $value;
@ -134,10 +139,10 @@ class Mapping
}
}
// get linked admin views
$addadmin_views = ComponentbuilderHelper::getVar('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views');
if (ComponentbuilderHelper::checkJson($addadmin_views))
$addadmin_views = GetHelper::var('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views');
if (JsonHelper::check($addadmin_views))
{
$this->addadmin_views = json_decode($addadmin_views, true);
$this->addadmin_views = json_decode((string)$addadmin_views, true);
}
// set the map of the views needed
if ($this->setMap())
@ -173,7 +178,7 @@ class Mapping
{
// start parsing the sql dump data
$queries = JDatabaseDriver::splitSql($this->buildcompsql);
if (ComponentbuilderHelper::checkArray($queries))
if (ArrayHelper::check($queries))
{
foreach ($queries as $query)
{
@ -208,7 +213,7 @@ class Mapping
}
}
// check if the mapping was done
if (ComponentbuilderHelper::checkArray($this->map))
if (ArrayHelper::check($this->map))
{
return true;
}
@ -224,12 +229,12 @@ class Mapping
if (strpos($query, '`#__') !== false)
{
// get table name
$tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`");
$tableName = GetHelper::between($query, '`#__', "`");
}
elseif (strpos($query, "'#__") !== false)
{
// get table name
$tableName = ComponentbuilderHelper::getBetween($query, "'#__", "'");
$tableName = GetHelper::between($query, "'#__", "'");
}
// if it still was not found
if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName))
@ -267,12 +272,12 @@ class Mapping
if (0 === strpos($row, '`'))
{
// get field name
$name = ComponentbuilderHelper::getBetween($row, '`', '`');
$name = GetHelper::between($row, '`', '`');
}
if (0 === strpos($row, "'"))
{
// get field name
$name = ComponentbuilderHelper::getBetween($row, "'", "'");
$name = GetHelper::between($row, "'", "'");
}
// check if the name was found
if (ComponentbuilderHelper::checkString($name))
@ -289,7 +294,7 @@ class Mapping
{
$field['row'] = $row;
$field['name'] = $name;
$field['label'] = ComponentbuilderHelper::safeString($name, 'W');
$field['label'] = StringHelper::check($name, 'W');
$field['fieldType'] = $fieldType;
$field['size'] = $this->getSize($row, $field);
$field['sizeOther'] = '';
@ -319,7 +324,7 @@ class Mapping
}
}
}
if (ComponentbuilderHelper::checkArray($fields))
if (ArrayHelper::check($fields))
{
return $fields;
}
@ -352,7 +357,7 @@ class Mapping
{
if (in_array($field['dataType'], $this->dataSize))
{
return ComponentbuilderHelper::getBetween($row, $field['dataType'].'(', ')');
return GetHelper::between($row, $field['dataType'].'(', ')');
}
return '';
}
@ -365,12 +370,12 @@ class Mapping
// get default value
if (strpos($row, 'DEFAULT "') !== false) // to sure it this is correct...
{
return ComponentbuilderHelper::getBetween($row, 'DEFAULT "', '"');
return GetHelper::between($row, 'DEFAULT "', '"');
}
// get default value
if (strpos($row, "DEFAULT '") !== false)
{
return ComponentbuilderHelper::getBetween($row, "DEFAULT '", "'");
return GetHelper::between($row, "DEFAULT '", "'");
}
return '';
}

View File

@ -26,6 +26,10 @@
// 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
*/
@ -102,7 +106,7 @@ class Builder extends Mapping
{
// set the view object
$object = new stdClass();
$object->system_name = ComponentbuilderHelper::safeString($name, 'W') . ' (dynamic build)';
$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)';
@ -257,14 +261,14 @@ class Builder extends Mapping
}
return false;
}
/**
* get the field type id from system
*/
protected function getFieldType($fieldName)
{
// load the field settings
return ComponentbuilderHelper::getVar('fieldtype', $fieldName, 'name', 'id');
return GetHelper::var('fieldtype', $fieldName, 'name', 'id');
}
/**

View File

@ -26,6 +26,9 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Extrusion class
*/
@ -58,10 +61,10 @@ class Extrusion extends Builder
protected function setAdminViews(&$component_id)
{
// check if views were set
if (ComponentbuilderHelper::checkArray($this->views))
if (ArrayHelper::check($this->views))
{
$count = 0;
if (ComponentbuilderHelper::checkArray($this->addadmin_views))
if (ArrayHelper::check($this->addadmin_views))
{
$count = (int) count((array)$this->addadmin_views) + 3;
}
@ -84,7 +87,7 @@ class Extrusion extends Builder
$this->addadmin_views['addadmin_views'.$pointer]['order'] = $pointer + 1;
}
}
if (isset($this->addadmin_views) && ComponentbuilderHelper::checkArray($this->addadmin_views))
if (isset($this->addadmin_views) && ArrayHelper::check($this->addadmin_views))
{
// set the field object
$object = new stdClass();
@ -94,7 +97,7 @@ class Extrusion extends Builder
$object->created_by = $this->user->id;
$object->published = 1;
// check if it is already set
if ($item_id = ComponentbuilderHelper::getVar('component_admin_views', $component_id, 'joomla_component', 'id'))
if ($item_id = GetHelper::var('component_admin_views', $component_id, 'joomla_component', 'id'))
{
// set ID
$object->id = (int) $item_id;

View File

@ -1,7 +0,0 @@
in
public
extends
private
protected
implements
instanceof

View File

@ -1,28 +0,0 @@
do
in
let
new
var
case
else
enum
void
with
class
const
yield
delete
export
import
public
return
static
typeof
extends
package
private
continue
function
protected
implements
instanceof

View File

@ -1,47 +0,0 @@
do
if
in
for
let
new
try
var
case
else
enum
eval
null
this
true
void
with
break
catch
class
const
false
super
throw
while
yield
delete
export
import
public
return
static
switch
typeof
default
extends
finally
package
private
continue
debugger
function
arguments
interface
protected
implements
instanceof

View File

@ -1,381 +0,0 @@
<?php
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
| |
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@created 30th April, 2015
@package Component Builder
@subpackage minify.php
@author Llewellyn van der Merwe <http://joomlacomponentbuilder.com>
@github Joomla Component Builder <https://github.com/vdm-io/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');
/**
* Abstract minifier class.
*
* Please report bugs on https://github.com/matthiasmullie/minify/issues
*
* @author Matthias Mullie <minify@mullie.eu>
*
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved.
* @license MIT License
*/
abstract class Minify
{
/**
* The data to be minified
*
* @var string[]
*/
protected $data = array();
/**
* Array of patterns to match.
*
* @var string[]
*/
protected $patterns = array();
/**
* This array will hold content of strings and regular expressions that have
* been extracted from the JS source code, so we can reliably match "code",
* without having to worry about potential "code-like" characters inside.
*
* @var string[]
*/
public $extracted = array();
/**
* Init the minify class - optionally, code may be passed along already.
*/
public function __construct(/* $data = null, ... */)
{
// it's possible to add the source through the constructor as well ;)
if (func_num_args()) {
call_user_func_array(array($this, 'add'), func_get_args());
}
}
/**
* Add a file or straight-up code to be minified.
*
* @param string $data
*/
public function add($data /* $data = null, ... */)
{
// bogus "usage" of parameter $data: scrutinizer warns this variable is
// not used (we're using func_get_args instead to support overloading),
// but it still needs to be defined because it makes no sense to have
// this function without argument :)
$args = array($data) + func_get_args();
// this method can be overloaded
foreach ($args as $data) {
// redefine var
$data = (string) $data;
// load data
$value = $this->load($data);
$key = ($data != $value) ? $data : count($this->data);
// store data
$this->data[$key] = $value;
}
}
/**
* Load data.
*
* @param string $data Either a path to a file or the content itself.
* @return string
*/
protected function load($data)
{
// check if the data is a file
if (@file_exists($data) && is_file($data)) {
$data = @file_get_contents($data);
// strip BOM, if any
if (substr($data, 0, 3) == "\xef\xbb\xbf") {
$data = substr($data, 3);
}
}
return $data;
}
/**
* Save to file
*
* @param string $content The minified data.
* @param string $path The path to save the minified data to.
* @throws Exception
*/
protected function save($content, $path)
{
// create file & open for writing
if (($handler = @fopen($path, 'w')) === false) {
throw new Exception('The file "'.$path.'" could not be opened. Check if PHP has enough permissions.');
}
// write to file
if (@fwrite($handler, $content) === false) {
throw new Exception('The file "'.$path.'" could not be written to. Check if PHP has enough permissions.');
}
// close the file
@fclose($handler);
}
/**
* Minify the data & (optionally) saves it to a file.
*
* @param string[optional] $path Path to write the data to.
* @return string The minified data.
*/
public function minify($path = null)
{
$content = $this->execute($path);
// save to path
if ($path !== null) {
$this->save($content, $path);
}
return $content;
}
/**
* Minify & gzip the data & (optionally) saves it to a file.
*
* @param string[optional] $path Path to write the data to.
* @param int[optional] $level Compression level, from 0 to 9.
* @return string The minified & gzipped data.
*/
public function gzip($path = null, $level = 9)
{
$content = $this->execute($path);
$content = gzencode($content, $level, FORCE_GZIP);
// save to path
if ($path !== null) {
$this->save($content, $path);
}
return $content;
}
/**
* Minify the data.
*
* @param string[optional] $path Path to write the data to.
* @return string The minified data.
*/
abstract protected function execute($path = null);
/**
* Register a pattern to execute against the source content.
*
* @param string $pattern PCRE pattern.
* @param string|callable $replacement Replacement value for matched pattern.
* @throws Exception
*/
protected function registerPattern($pattern, $replacement = '')
{
// study the pattern, we'll execute it more than once
$pattern .= 'S';
$this->patterns[] = array($pattern, $replacement);
}
/**
* We can't "just" run some regular expressions against JavaScript: it's a
* complex language. E.g. having an occurrence of // xyz would be a comment,
* unless it's used within a string. Of you could have something that looks
* like a 'string', but inside a comment.
* The only way to accurately replace these pieces is to traverse the JS one
* character at a time and try to find whatever starts first.
*
* @param string $content The content to replace patterns in.
* @return string The (manipulated) content.
*/
protected function replace($content)
{
$processed = '';
$positions = array_fill(0, count($this->patterns), -1);
$matches = array();
while ($content) {
// find first match for all patterns
foreach ($this->patterns as $i => $pattern) {
list($pattern, $replacement) = $pattern;
// no need to re-run matches that are still in the part of the
// content that hasn't been processed
if ($positions[$i] >= 0) {
continue;
}
$match = null;
if (preg_match($pattern, $content, $match)) {
$matches[$i] = $match;
// we'll store the match position as well; that way, we
// don't have to redo all preg_matches after changing only
// the first (we'll still know where those others are)
$positions[$i] = strpos($content, $match[0]);
} else {
// if the pattern couldn't be matched, there's no point in
// executing it again in later runs on this same content;
// ignore this one until we reach end of content
unset($matches[$i]);
$positions[$i] = strlen($content);
}
}
// no more matches to find: everything's been processed, break out
if (!$matches) {
$processed .= $content;
break;
}
// see which of the patterns actually found the first thing (we'll
// only want to execute that one, since we're unsure if what the
// other found was not inside what the first found)
$discardLength = min($positions);
$firstPattern = array_search($discardLength, $positions);
$match = $matches[$firstPattern][0];
// execute the pattern that matches earliest in the content string
list($pattern, $replacement) = $this->patterns[$firstPattern];
$replacement = $this->replacePattern($pattern, $replacement, $content);
// figure out which part of the string was unmatched; that's the
// part we'll execute the patterns on again next
$content = substr($content, $discardLength);
$unmatched = (string) substr($content, strpos($content, $match) + strlen($match));
// move the replaced part to $processed and prepare $content to
// again match batch of patterns against
$processed .= substr($replacement, 0, strlen($replacement) - strlen($unmatched));
$content = $unmatched;
// first match has been replaced & that content is to be left alone,
// the next matches will start after this replacement, so we should
// fix their offsets
foreach ($positions as $i => $position) {
$positions[$i] -= $discardLength + strlen($match);
}
}
return $processed;
}
/**
* This is where a pattern is matched against $content and the matches
* are replaced by their respective value.
* This function will be called plenty of times, where $content will always
* move up 1 character.
*
* @param string $pattern Pattern to match.
* @param string|callable $replacement Replacement value.
* @param string $content Content to match pattern against.
* @return string
*/
protected function replacePattern($pattern, $replacement, $content)
{
if (is_callable($replacement)) {
return preg_replace_callback($pattern, $replacement, $content, 1, $count);
} else {
return preg_replace($pattern, $replacement, $content, 1, $count);
}
}
/**
* Strings are a pattern we need to match, in order to ignore potential
* code-like content inside them, but we just want all of the string
* content to remain untouched.
*
* This method will replace all string content with simple STRING#
* placeholder text, so we've rid all strings from characters that may be
* misinterpreted. Original string content will be saved in $this->extracted
* and after doing all other minifying, we can restore the original content
* via restoreStrings()
*
* @param string[optional] $chars
*/
protected function extractStrings($chars = '\'"')
{
// PHP only supports $this inside anonymous functions since 5.4
$minifier = $this;
$callback = function ($match) use ($minifier) {
if (!$match[1]) {
/*
* Empty strings need no placeholder; they can't be confused for
* anything else anyway.
* But we still needed to match them, for the extraction routine
* to skip over this particular string.
*/
return $match[0];
}
$count = count($minifier->extracted);
$placeholder = $match[1].$count.$match[1];
$minifier->extracted[$placeholder] = $match[1].$match[2].$match[1];
return $placeholder;
};
/*
* The \\ messiness explained:
* * Don't count ' or " as end-of-string if it's escaped (has backslash
* in front of it)
* * Unless... that backslash itself is escaped (another leading slash),
* in which case it's no longer escaping the ' or "
* * So there can be either no backslash, or an even number
* * multiply all of that times 4, to account for the escaping that has
* to be done to pass the backslash into the PHP string without it being
* considered as escape-char (times 2) and to get it in the regex,
* escaped (times 2)
*/
$this->registerPattern('/(['.$chars.'])(.*?((?<!\\\\)|\\\\\\\\+))\\1/s', $callback);
}
/**
* This method will restore all extracted data (strings, regexes) that were
* replaced with placeholder text in extract*(). The original content was
* saved in $this->extracted.
*
* @param string $content
* @return string
*/
protected function restoreExtractedData($content)
{
if (!$this->extracted) {
// nothing was extracted, nothing to restore
return $content;
}
$content = strtr($content, $this->extracted);
$this->extracted = array();
return $content;
}
}

View File

@ -1,45 +0,0 @@
+
-
*
/
%
=
+=
-=
*=
/=
%=
<<=
>>=
>>>=
&=
^=
|=
&
|
^
~
<<
>>
>>>
==
===
!=
!==
>
<
>=
<=
&&
||
.
[
]
?
:
,
;
(
)
{
}

View File

@ -1,43 +0,0 @@
+
-
*
/
%
=
+=
-=
*=
/=
%=
<<=
>>=
>>>=
&=
^=
|=
&
|
^
~
<<
>>
>>>
==
===
!=
!==
>
<
>=
<=
&&
||
!
.
[
?
:
,
;
(
{

View File

@ -1318,6 +1318,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 <b>script.php</b> 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="<a %s ><span class="icon-flag"> </span>Report Broken Package</a>"
COM_COMPONENTBUILDER_BACK="Back"
COM_COMPONENTBUILDER_BACKUP="Backup"
@ -1651,6 +1652,7 @@ COM_COMPONENTBUILDER_CLASS_PROPERTY_VERSION_DESC="A count of the number of times
COM_COMPONENTBUILDER_CLASS_PROPERTY_VERSION_LABEL="Version"
COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_DESCRIPTION="The visibility of a function/method or property can be defined by prefixing the declaration with the keywords public, protected or private. You also have the option to make function/method or property static."
COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_LABEL="Visibility"
COM_COMPONENTBUILDER_CLEAR="Clear"
COM_COMPONENTBUILDER_CLEAR_TMP="Clear tmp"
COM_COMPONENTBUILDER_CLONE="Clone"
COM_COMPONENTBUILDER_CLONE_FAILED="Clone failed!"
@ -5602,9 +5604,11 @@ 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 <a %s >free keys</a> from VDM."
COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="<hr /><h3>Custom Codes Warning</h3>"
COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE="<hr /><h3>Dynamic folder(s) were detected.</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE="<hr /><h3>Field Notice</h3>"
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="<h3>Placeholder Removed!</h3><p><b>This</b> custom code can only be used in <b>other</b> custom code, not in it self! Since that will cause a infinite loop in the compiler.</p>"
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="<h3>%s</h3><p>Custom code can only be used in other custom code if set as <b>JCB (manual)</b>, you can not add them to <em>Hash (Automation)</em> code at this point.</p>"
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="<h3>%s namespace error (%s)</h3><p>You must at-least have two sections in your namespace, you just have one (%s). This is an unacceptable action, please see <a href=%s >psr-4</a> for more info.</p><p>This %s was therefore removed, <a href=%s>click here</a> to fix this issue.</p>"
@ -8011,13 +8015,29 @@ COM_COMPONENTBUILDER_POWERS_N_ITEMS_UNPUBLISHED_1="%s Power unpublished."
COM_COMPONENTBUILDER_POWERS_SUBMENU="Powers Submenu"
COM_COMPONENTBUILDER_POWERS_SUBMENU_DESC="Allows the users in this group to submenu of power"
COM_COMPONENTBUILDER_POWER_ABSTRACT_CLASS="abstract class"
COM_COMPONENTBUILDER_POWER_ACCESS_POINT_DESCRIPTION="Library path to the autoload.php file"
COM_COMPONENTBUILDER_POWER_ACCESS_POINT_HINT="custom_folder/vendor/autoload.php (must be in the .../public_html/library/ folder of Joomla)"
COM_COMPONENTBUILDER_POWER_ACCESS_POINT_LABEL="Access Point"
COM_COMPONENTBUILDER_POWER_ACCESS_POINT_MESSAGE="Error! Please add autoload full path here."
COM_COMPONENTBUILDER_POWER_ADD_HEAD_DESCRIPTION="You can add your own custom header script, combined with the default header script that make the extended class work."
COM_COMPONENTBUILDER_POWER_ADD_HEAD_LABEL="Add Custom Class Header"
COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION="The option to override the licensing template."
COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL="Add Licensing Template"
COM_COMPONENTBUILDER_POWER_AS_LABEL="as"
COM_COMPONENTBUILDER_POWER_AUTOLOAD_COMPOSER_NOTE_DESCRIPTION="<p>Once you have manually pulled composer classes into your own custom folder in libraries area (via composer), you can link it here.</p>
<p>So this feature gives you the ability to add your own custom <b>composer</b> set of classes to your project. Yes, you will still have to manually pull them into your own custom and unique folder into the libraries area of Joomla (on this JCB development system). But you can link it here and JCB will take care of adding it to your component.</p>
<p>First and most importantly (due to obvious risk of collusion), avoid pulling classes into your custom set of composer classes that are already included in the Joomla vendor folder. Those classes that Joomla loads are already available to you. To use them, just add the <b>use Namespace;</b> of that class to the header of this power, and the PHP auto linker will take care of the rest.</p>
<p>So all composer projects =>(vendor folders) has an <code>autoload.php</code> file that is located in the root of the vendor folder. We call this the <b>access point</b> to that cluster of classes. This means you will have <b>one access point</b> for multiple namespaces.</p>
<p>Due the continued risk of collusion <b>we allow only one access point per/power</b>. But for even more peace of mind, it is best to have only one access point per/project. Which means you should try to consolidate your custom composer additional classes (outside of the Joomla vendor folder) into one vendor folder. This will result in <b>one access point</b>, that you will use multiple times for various powers.</p>"
COM_COMPONENTBUILDER_POWER_AUTOLOAD_COMPOSER_NOTE_LABEL="When to use Autoloader Composer Powers?"
COM_COMPONENTBUILDER_POWER_CLASS="class"
COM_COMPONENTBUILDER_POWER_CODE="Code"
COM_COMPONENTBUILDER_POWER_COMPOSER="Composer"
COM_COMPONENTBUILDER_POWER_COMPOSER_LABEL="Autoloader Composer Powers"
COM_COMPONENTBUILDER_POWER_CREATED_BY_DESC="The user that created this Power."
COM_COMPONENTBUILDER_POWER_CREATED_BY_LABEL="Created By"
COM_COMPONENTBUILDER_POWER_CREATED_DATE_DESC="The date this Power was created."
@ -8135,7 +8155,9 @@ COM_COMPONENTBUILDER_POWER_TYPE_DESCRIPTION="The type of power being build"
COM_COMPONENTBUILDER_POWER_TYPE_LABEL="Type of Power"
COM_COMPONENTBUILDER_POWER_USE="Use"
COM_COMPONENTBUILDER_POWER_USE_GLOBAL="Use Global"
COM_COMPONENTBUILDER_POWER_USE_LABEL="use"
COM_COMPONENTBUILDER_POWER_USE_HINT="Name\Project\ClassName"
COM_COMPONENTBUILDER_POWER_USE_LABEL="Use"
COM_COMPONENTBUILDER_POWER_USE_MESSAGE="Error! Please add namespace here."
COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION="Select namespace you want to use in your power."
COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL="Use Selection"
COM_COMPONENTBUILDER_POWER_VERSION_DESC="A count of the number of times this Power has been revised."

View File

@ -0,0 +1,45 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// 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(
'autoload_composer_note',
'composer'
);
$hiddenFields = $displayData->get('hidden_fields') ?: array();
?>
<?php if ($fields && count((array) $fields)) :?>
<div class="form-vertical">
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>

View File

@ -186,22 +186,6 @@
</field>
<!-- Load_powers_note Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="load_powers_note" label="COM_COMPONENTBUILDER_POWER_LOAD_POWERS_NOTE_LABEL" description="COM_COMPONENTBUILDER_POWER_LOAD_POWERS_NOTE_DESCRIPTION" heading="h4" class="alert alert-info load_powers_note" />
<!-- Main_class_code Field. Type: Editor. (joomla) -->
<field
type="editor"
name="main_class_code"
label="COM_COMPONENTBUILDER_POWER_MAIN_CLASS_CODE_LABEL"
description="COM_COMPONENTBUILDER_POWER_MAIN_CLASS_CODE_DESCRIPTION"
width="100%"
height="800px"
cols="40"
rows="300"
buttons="no"
syntax="php"
editor="codemirror|none"
filter="raw"
validate="code"
/>
<!-- Description Field. Type: Textarea. (joomla) -->
<field
type="textarea"
@ -227,6 +211,63 @@
validate="code"
showon="add_licensing_template:2"
/>
<!-- Composer Field. Type: Subform. (joomla) -->
<field
type="subform"
name="composer"
label="COM_COMPONENTBUILDER_POWER_COMPOSER_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
icon="list"
max="1"
min="0">
<form hidden="true" name="list_composer_modal" repeat="true">
<!-- Access_point Field. Type: Text. (joomla) -->
<field
type="text"
name="access_point"
label="COM_COMPONENTBUILDER_POWER_ACCESS_POINT_LABEL"
size="70"
maxlength="300"
description="COM_COMPONENTBUILDER_POWER_ACCESS_POINT_DESCRIPTION"
class="text_area"
required="true"
filter="PATH"
message="COM_COMPONENTBUILDER_POWER_ACCESS_POINT_MESSAGE"
hint="COM_COMPONENTBUILDER_POWER_ACCESS_POINT_HINT"
/>
<!-- Namespace Field. Type: Subform. (joomla) -->
<field
type="subform"
name="namespace"
label="COM_COMPONENTBUILDER_POWER_NAMESPACE_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
icon="list"
max="30"
min="1"
nested_depth="1">
<form hidden="true" name="list_namespace_modal" repeat="true">
<!-- Use Field. Type: Text. (joomla) -->
<field
type="text"
name="use"
label="COM_COMPONENTBUILDER_POWER_USE_LABEL"
size="70"
maxlength="300"
class="text_area"
required="true"
filter="STRING"
message="COM_COMPONENTBUILDER_POWER_USE_MESSAGE"
hint="COM_COMPONENTBUILDER_POWER_USE_HINT"
autocomplete="on"
/>
</form>
</field>
</form>
</field>
<!-- Property_selection Field. Type: Subform. (joomla) -->
<field
type="subform"
@ -372,21 +413,8 @@
required="false"
validate="code"
/>
<!-- Add_licensing_template Field. Type: Radio. (joomla) -->
<field
type="radio"
name="add_licensing_template"
label="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL"
description="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_POWER_USE_GLOBAL</option>
<option value="2">
COM_COMPONENTBUILDER_POWER_OVERRIDE</option>
</field>
<!-- Autoload_composer_note Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="autoload_composer_note" label="COM_COMPONENTBUILDER_POWER_AUTOLOAD_COMPOSER_NOTE_LABEL" description="COM_COMPONENTBUILDER_POWER_AUTOLOAD_COMPOSER_NOTE_DESCRIPTION" heading="h4" class="alert alert-info autoload_composer_note" />
<!-- Use_selection Field. Type: Subform. (joomla) -->
<field
type="subform"
@ -397,9 +425,8 @@
buttons="add,remove,move"
description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION"
icon="list"
max="30"
min="0"
showon="type!:interface">
max="100"
min="0">
<form hidden="true" name="list_use_selection_modal" repeat="true">
<!-- Use Field. Type: Namespaces. (custom) -->
<field
@ -425,6 +452,37 @@
/>
</form>
</field>
<!-- Add_licensing_template Field. Type: Radio. (joomla) -->
<field
type="radio"
name="add_licensing_template"
label="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL"
description="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_POWER_USE_GLOBAL</option>
<option value="2">
COM_COMPONENTBUILDER_POWER_OVERRIDE</option>
</field>
<!-- Main_class_code Field. Type: Editor. (joomla) -->
<field
type="editor"
name="main_class_code"
label="COM_COMPONENTBUILDER_POWER_MAIN_CLASS_CODE_LABEL"
description="COM_COMPONENTBUILDER_POWER_MAIN_CLASS_CODE_DESCRIPTION"
width="100%"
height="800px"
cols="40"
rows="300"
buttons="no"
syntax="php"
editor="codemirror|none"
filter="raw"
validate="code"
/>
<!-- Guid Field. Type: Text. (joomla) -->
<field
type="text"

View File

@ -14,6 +14,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory;
/**
* Joomla_components List Model

View File

@ -64,6 +64,12 @@ class ComponentbuilderModelPower extends AdminModel
'add_licensing_template',
'licensing_template'
)
),
'composer' => array(
'fullwidth' => array(
'autoload_composer_note',
'composer'
)
)
);
@ -178,12 +184,6 @@ class ComponentbuilderModelPower extends AdminModel
$item->metadata = $registry->toArray();
}
if (!empty($item->main_class_code))
{
// base64 Decode main_class_code.
$item->main_class_code = base64_decode($item->main_class_code);
}
if (!empty($item->licensing_template))
{
// base64 Decode licensing_template.
@ -196,6 +196,12 @@ class ComponentbuilderModelPower extends AdminModel
$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->load_selection))
{
// Convert the load_selection field to an array.
@ -204,6 +210,14 @@ class ComponentbuilderModelPower extends AdminModel
$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.
@ -1050,6 +1064,19 @@ class ComponentbuilderModelPower extends AdminModel
$data['load_selection'] = '';
}
// Set the composer items to data.
if (isset($data['composer']) && is_array($data['composer']))
{
$composer = new JRegistry;
$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']))
{
@ -1102,12 +1129,6 @@ class ComponentbuilderModelPower extends AdminModel
$data['use_selection'] = '';
}
// 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 licensing_template string to base64 string.
if (isset($data['licensing_template']))
{
@ -1119,6 +1140,12 @@ class ComponentbuilderModelPower extends AdminModel
{
$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']))

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
ALTER TABLE `#__componentbuilder_power` ADD `composer` TEXT NOT NULL AFTER `add_licensing_template`;

View File

@ -92,7 +92,6 @@ class ComponentbuilderViewGet_snippets extends HtmlView
{
// Set the default uikit components in this view.
$uikitComp = array();
$uikitComp[] = 'UIkit.notify';
$uikitComp[] = 'data-uk-grid';
}

View File

@ -64,6 +64,16 @@ $componentParams = $this->params; // will be removed just use $this->params inst
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'powerTab', 'composer', JText::_('COM_COMPONENTBUILDER_POWER_COMPOSER', true)); ?>
<div class="row-fluid form-horizontal-desktop">
</div>
<div class="row-fluid form-horizontal-desktop">
<div class="span12">
<?php echo JLayoutHelper::render('power.composer_fullwidth', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'powerTab', 'licensing', JText::_('COM_COMPONENTBUILDER_POWER_LICENSING', true)); ?>
<div class="row-fluid form-horizontal-desktop">
</div>

View File

@ -329,8 +329,8 @@ document.addEventListener('DOMContentLoaded', function () {
tableLengthObject = document.getElementById("search_results_table_length");
showSearch();
<?php if (strlen($this->urlvalues['search_value']) > 2): ?>
startSearch();
<?php if (strlen($this->urlvalues['search_value']) > 0): ?>
startSearch(null, true);
<?php endif; ?>
});
</script>

View File

@ -137,7 +137,8 @@ class ComponentbuilderViewSearch extends HtmlView
// set the mode options
$options = [
1 => 'COM_COMPONENTBUILDER_SEARCH',
2 => 'COM_COMPONENTBUILDER_REPLACE'];
2 => 'COM_COMPONENTBUILDER_REPLACE',
0 => 'COM_COMPONENTBUILDER_CLEAR'];
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
if ($xml instanceof SimpleXMLElement)

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>13th November, 2022</creationDate>
<creationDate>29th January, 2023</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>3.1.12</version>
<version>3.1.13</version>
<description><![CDATA[
<h1>Component Builder (v.3.1.12)</h1>
<h1>Component Builder (v.3.1.13)</h1>
<div style="clear: both;"></div>
<p>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.
<p>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!</p>
<p>Created by <a href="https://dev.vdm.io" target="_blank">Llewellyn van der Merwe</a><br /><small>Development started 30th April, 2015</small></p>
]]></description>
@ -124,4 +124,4 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo
<updateservers>
<server type="extension" enabled="1" element="com_componentbuilder" name="Component Builder">https://git.vdm.dev/joomla/Component-Builder/raw/branch/master/componentbuilder_update_server.xml</server>
</updateservers>
</extension>
</extension>

View File

@ -1109,4 +1109,21 @@
<maintainerurl>https://dev.vdm.io</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
<update>
<name>Component Builder</name>
<description>Builds Complex Joomla Components</description>
<element>com_componentbuilder</element>
<type>component</type>
<version>3.1.13</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">http://domain.com/demo.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://dev.vdm.io</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
</updates>

View File

@ -58,7 +58,7 @@ abstract class AbstractGiteaObject
$this->options = $options ?: new Registry;
$this->client = $client ?: (new HttpFactory)->getHttp($this->options);
$this->package = \get_class($this);
$this->package = static::class;
$this->package = substr($this->package, strrpos($this->package, '\\') + 1);
}
@ -83,7 +83,7 @@ abstract class AbstractGiteaObject
if ($this->options->get('access.token', false))
{
// Use oAuth authentication
$headers = $this->client->getOption('headers', array());
$headers = $this->client->getOption('headers', []);
if (!isset($headers['Authorization']))
{
@ -137,7 +137,7 @@ abstract class AbstractGiteaObject
if ($response->code != $expectedCode)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
$error = json_decode((string) $response->body);
$message = isset($error->message) ? $error->message : 'Invalid response received from Gitea.';
throw new \DomainException($message, $response->code);
@ -145,11 +145,11 @@ abstract class AbstractGiteaObject
if (JsonHelper::check($response->body))
{
$body = json_decode($response->body);
$body = json_decode((string) $response->body);
if (isset($body->content_base64))
{
$body->content = base64_decode($body->content_base64);
$body->content = base64_decode((string) $body->content_base64);
}
}
else

View File

@ -30,7 +30,7 @@ abstract class AbstractPackage extends AbstractGiteaObject
{
parent::__construct($options, $client);
$this->package = \get_class($this);
$this->package = static::class;
$this->package = substr($this->package, strrpos($this->package, '\\') + 1);
}

View File

@ -70,7 +70,7 @@ class Wiki extends AbstractPackage
$path = '/markdown';
// Get headers
$headers = $this->client->getOption('headers', array());
$headers = $this->client->getOption('headers', []);
$headers['accept'] = 'text/html';
$headers['Content-Type'] = 'application/json';

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -32,7 +32,7 @@ abstract class BaseConfig extends JoomlaRegistry
* @var Input
* @since 3.2.0
*/
protected $input;
protected Input $input;
/**
* The Params
@ -66,12 +66,12 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* setting any config value
*
* @param String $key The value's key/path name
* @param string $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @since 3.2.0
*/
public function __set($key, $value)
public function __set(string $key, $value)
{
$this->set($key, $value);
}
@ -79,12 +79,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($key)
public function __get(string $key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
@ -98,7 +98,7 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* Get a config value.
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
* @param string $path Registry path (e.g. joomla_content_showauthor)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
@ -108,7 +108,7 @@ abstract class BaseConfig extends JoomlaRegistry
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $path)));
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
@ -117,7 +117,7 @@ abstract class BaseConfig extends JoomlaRegistry
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
$value = $this->{$method}($default);
$this->set($path, $value);
@ -126,6 +126,27 @@ abstract class BaseConfig extends JoomlaRegistry
return $default;
}
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -29,11 +29,11 @@ abstract class BaseRegistry extends JoomlaRegistry implements \JsonSerializable,
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return \ArrayIterator This object represented as an ArrayIterator.
* @return \ArrayIterator|null This object represented as an ArrayIterator.
*
* @since 3.4.0
*/
public function _($path)
public function _(string $path): ?\ArrayIterator
{
$data = $this->extract($path);
@ -44,6 +44,107 @@ abstract class BaseRegistry extends JoomlaRegistry implements \JsonSerializable,
return $data->getIterator();
}
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
/**
* Check if a registry path exists and is an array
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isArray(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_array($node)
&& $node !== [])
{
return true;
}
return false;
}
/**
* Check if a registry path exists and is a string
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isString(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_string($node)
&& strlen((string) $node) > 0)
{
return true;
}
return false;
}
/**
* Check if a registry path exists and is numeric
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isNumeric(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_numeric($node))
{
return true;
}
return false;
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Abstraction;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Database
*
* @since 3.2.0
*/
abstract class Database
{
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
*/
protected \JDatabaseDriver $db;
/**
* Core Component Table Name
*
* @var string
* @since 3.2.0
*/
protected string $table;
/**
* Constructor
*
* @param \JDatabaseDriver|null $db The database driver
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?\JDatabaseDriver $db = null)
{
$this->db = $db ?: JoomlaFactory::getDbo();
// set the component table
$this->table = '#__' . Helper::getCode();
}
/**
* Set a value based on data type
*
* @param mixed $value The value to set
*
* @return mixed
* @since 3.2.0
**/
protected function quote($value)
{
if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
return (int) $value;
}
elseif (filter_var($value, FILTER_VALIDATE_FLOAT))
{
return (float) $value;
}
}
elseif (is_bool($value))
{
return (int) $value;
}
// default just escape it
return $this->db->quote($value);
}
/**
* Set a table name, adding the
* core component as needed
*
* @param string $table The table string
*
* @return string
* @since 3.2.0
**/
protected function getTable(string $table): string
{
if (strpos($table, '#__') === false)
{
return $this->table . '_' . $table;
}
return $table;
}
}

View File

@ -0,0 +1,258 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Abstraction;
use VDM\Joomla\Componentbuilder\Interfaces\Mapperdoubleinterface;
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
/**
* Compiler Mapper
*
* @since 3.2.0
*/
abstract class Mapper implements Mapperdoubleinterface, Mappersingleinterface
{
/**
* The Content
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* Set content
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set(string $key, $value)
{
$this->active[$this->key($key)] = $value;
}
/**
* Get content
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $key)
{
return $this->active[$this->key($key)] ?? null;
}
/**
* Does key exist
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist(string $key): bool
{
if (isset($this->active[$this->key($key)]))
{
return true;
}
return false;
}
/**
* Add content
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add(string $key, $value)
{
if (isset($this->active[$this->key($key)]))
{
$this->active[$this->key($key)] .= $value;
}
else
{
$this->active[$this->key($key)] = $value;
}
}
/**
* Remove content
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove(string $key)
{
unset($this->active[$this->key($key)]);
}
/**
* Model the key
*
* @param string $key The key to model
*
* @return string
* @since 3.2.0
*/
abstract protected function key(string $key): string;
/**
* The Dynamic Content
*
* @var array
* @since 3.2.0
**/
public array $_active = [];
/**
* Set dynamic content
*
* @param string $firstKey The first key
* @param string $secondKey The second key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_(string $firstKey, string $secondKey, $value)
{
$this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)] = $value;
}
/**
* Get dynamic content
*
* @param string $firstKey The first key
* @param string|null $secondKey The second key
*
* @return mixed
* @since 3.2.0
*/
public function get_(string $firstKey, ?string $secondKey = null)
{
if (is_string($secondKey))
{
return $this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)] ?? null;
}
return $this->_active[$this->firstKey($firstKey)] ?? null;
}
/**
* Does keys exist
*
* @param string $firstKey The first key
* @param string|null $secondKey The second key
*
* @return bool
* @since 3.2.0
*/
public function exist_(string $firstKey, ?string $secondKey = null): bool
{
if (is_string($secondKey) && isset($this->_active[$this->firstKey($firstKey)]) &&
isset($this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)]))
{
return true;
}
elseif (is_null($secondKey) && isset($this->_active[$this->firstKey($firstKey)]))
{
return true;
}
return false;
}
/**
* Add dynamic content
*
* @param string $firstKey The first key
* @param string $secondKey The second key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_(string $firstKey, string $secondKey, $value)
{
if (isset($this->_active[$this->firstKey($firstKey)]) &&
isset($this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)]))
{
$this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)] .= $value;
}
else
{
$this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)] = $value;
}
}
/**
* Remove dynamic content
*
* @param string $firstKey The first key
* @param string|null $secondKey The second key
*
* @return void
* @since 3.2.0
*/
public function remove_(string $firstKey, ?string $secondKey = null)
{
if (is_string($secondKey))
{
unset($this->_active[$this->firstKey($firstKey)]
[$this->secondKey($secondKey)]);
}
else
{
unset($this->_active[$this->firstKey($firstKey)]);
}
}
/**
* Model the first key
*
* @param string $key The first key to model
*
* @return string
* @since 3.2.0
*/
abstract protected function firstKey(string $key): string;
/**
* Model the second key
*
* @param string $key The second key to model
*
* @return string
* @since 3.2.0
*/
abstract protected function secondKey(string $key): string;
}

View File

@ -0,0 +1,122 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Abstraction;
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
/**
* Compiler Mapper Single
*
* @since 3.2.0
*/
abstract class MapperSingle implements Mappersingleinterface
{
/**
* The Content
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* Set content
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set(string $key, $value)
{
$this->active[$this->key($key)] = $value;
}
/**
* Get content
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $key)
{
return $this->active[$this->key($key)] ?? null;
}
/**
* Does key exist
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist(string $key): bool
{
if (isset($this->active[$this->key($key)]))
{
return true;
}
return false;
}
/**
* Add content
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add(string $key, $value)
{
if (isset($this->active[$this->key($key)]))
{
$this->active[$this->key($key)] .= $value;
}
else
{
$this->active[$this->key($key)] = $value;
}
}
/**
* Remove content
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove(string $key)
{
unset($this->active[$this->key($key)]);
}
/**
* Model the key
*
* @param string $key The key to model
*
* @return string
* @since 3.2.0
*/
abstract protected function key(string $key): string;
}

View File

@ -2,25 +2,23 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Search\Abstraction;
namespace VDM\Joomla\Componentbuilder\Abstraction;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
use VDM\Joomla\Componentbuilder\Table;
/**
* Search Model
* Our base Model
*
* @since 3.2.0
*/
@ -34,14 +32,6 @@ abstract class Model
*/
protected array $last;
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
@ -53,17 +43,28 @@ abstract class Model
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Table $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null)
public function __construct(Table $table)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->table = $table;
}
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
abstract public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item('table_name', Object);
@ -79,14 +80,14 @@ abstract class Model
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
$table = $this->getTable();
}
// field counter
$field_number = 0;
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
if (($fields = $this->getTableFields($table)) !== null)
{
foreach ($fields as $field)
{
@ -95,14 +96,13 @@ abstract class Model
{
$item->{$field} = $this->value($item->{$field}, $field, $table);
// remove empty values
if (!StringHelper::check($item->{$field}) && !ArrayHelper::check($item->{$field}, true))
if ($this->validate($item->{$field}))
{
unset($item->{$field});
$field_number++;
}
else
{
$field_number++;
unset($item->{$field});
}
}
}
@ -135,7 +135,7 @@ abstract class Model
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
$table = $this->getTable();
}
foreach ($items as $id => &$item)
@ -175,7 +175,7 @@ abstract class Model
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
$table = $this->getTable();
}
// check if this is a valid table
@ -186,6 +186,48 @@ abstract class Model
return null;
}
/**
* Validate the values (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validate(&$value, ?string $field = null, ?string $table = null): bool
{
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
}
/**
* Get the current active table's fields
*
* @param string $table The table
*
* @return array
* @since 3.2.0
*/
protected function getTableFields(string $table): ?array
{
return $this->table->fields($table);
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
abstract protected function getTable(): string;
}

View File

@ -0,0 +1,545 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Adminview;
use Joomla\CMS\Factory;
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\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Fields;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Permissions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Relations;
use VDM\Joomla\Componentbuilder\Compiler\Model\Linkedviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customimportscripts;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customalias;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Mysqlsettings;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin View Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Admin views
*
* @var array
* @since 3.2.0
*/
protected array $data;
/**
* 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 Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The modelling customtabs
*
* @var Customtabs
* @since 3.2.0
*/
protected Customtabs $customtabs;
/**
* The modelling tabs
*
* @var Tabs
* @since 3.2.0
*/
protected Tabs $tabs;
/**
* The modelling fields
*
* @var Fields
* @since 3.2.0
*/
protected Fields $fields;
/**
* The modelling admin view history
*
* @var Historyadminview
* @since 3.2.0
*/
protected Historyadminview $history;
/**
* The modelling permissions
*
* @var Permissions
* @since 3.2.0
*/
protected Permissions $permissions;
/**
* The modelling conditions
*
* @var Conditions
* @since 3.2.0
*/
protected Conditions $conditions;
/**
* The modelling relations
*
* @var Relations
* @since 3.2.0
*/
protected Relations $relations;
/**
* The modelling linked views
*
* @var Linkedviews
* @since 3.2.0
*/
protected Linkedviews $linkedviews;
/**
* The modelling javascript
*
* @var Javascriptadminview
* @since 3.2.0
*/
protected Javascriptadminview $javascript;
/**
* The modelling css
*
* @var Cssadminview
* @since 3.2.0
*/
protected Cssadminview $css;
/**
* The modelling php admin view
*
* @var Phpadminview
* @since 3.2.0
*/
protected Phpadminview $php;
/**
* The modelling custom buttons
*
* @var Custombuttons
* @since 3.2.0
*/
protected Custombuttons $custombuttons;
/**
* The modelling custom import scripts
*
* @var Customimportscripts
* @since 3.2.0
*/
protected Customimportscripts $customimportscripts;
/**
* The modelling ajax
*
* @var Ajaxadmin
* @since 3.2.0
*/
protected Ajaxadmin $ajax;
/**
* The modelling custom alias
*
* @var Customalias
* @since 3.2.0
*/
protected Customalias $customalias;
/**
* The modelling sql
*
* @var Sql
* @since 3.2.0
*/
protected Sql $sql;
/**
* The modelling mysql settings
*
* @var Mysqlsettings
* @since 3.2.0
*/
protected Mysqlsettings $mysqlsettings;
/**
* 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 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 Dispenser|null $dispenser The compiler customcode dispenser object.
* @param Customtabs|null $customtabs The modelling customtabs object.
* @param Tabs|null $tabs The modelling tabs object.
* @param Fields|null $fields The modelling fields object.
* @param Historyadminview|null $history The modelling admin view history object.
* @param Permissions|null $permissions The modelling permissions object.
* @param Conditions|null $conditions The modelling conditions object.
* @param Relations|null $relations The modelling relations object.
* @param Linkedviews|null $linkedviews The modelling linked views object.
* @param Javascriptadminview|null $javascript The modelling javascript object.
* @param Cssadminview|null $css The modelling css object.
* @param Phpadminview|null $php The modelling php admin view object.
* @param Custombuttons|null $custombuttons The modelling custom buttons object.
* @param Customimportscripts|null $customimportscripts The modelling custom import scripts object.
* @param Ajaxadmin|null $ajax The modelling ajax object.
* @param Customalias|null $customalias The modelling custom alias object.
* @param Sql|null $sql The modelling sql object.
* @param Mysqlsettings|null $mysqlsettings The modelling mysql settings object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?EventInterface $event = null, ?Placeholder $placeholder = null, ?Dispenser $dispenser = null,
?Customtabs $customtabs = null, ?Tabs $tabs = null, ?Fields $fields = null,
?Historyadminview $history = null, ?Permissions $permissions = null,
?Conditions $conditions = null, Relations $relations = null, ?Linkedviews $linkedviews = null,
?Javascriptadminview $javascript = null, ?Cssadminview $css = null, ?Phpadminview $php = null,
?Custombuttons $custombuttons = null, ?Customimportscripts $customimportscripts = null,
?Ajaxadmin $ajax = null, ?Customalias $customalias = null, ?Sql $sql = null,
?Mysqlsettings $mysqlsettings = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->customtabs = $customtabs ?: Compiler::_('Model.Customtabs');
$this->tabs = $tabs ?: Compiler::_('Model.Tabs');
$this->fields = $fields ?: Compiler::_('Model.Fields');
$this->history = $history ?: Compiler::_('Model.Historyadminview');
$this->permissions = $permissions ?: Compiler::_('Model.Permissions');
$this->conditions = $conditions ?: Compiler::_('Model.Conditions');
$this->relations = $relations ?: Compiler::_('Model.Relations');
$this->linkedviews = $linkedviews ?: Compiler::_('Model.Linkedviews');
$this->javascript = $javascript ?: Compiler::_('Model.Javascriptadminview');
$this->css = $css ?: Compiler::_('Model.Cssadminview');
$this->php = $php ?: Compiler::_('Model.Phpadminview');
$this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons');
$this->customimportscripts = $customimportscripts ?: Compiler::_('Model.Customimportscripts');
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxadmin');
$this->customalias = $customalias ?: Compiler::_('Model.Customalias');
$this->sql = $sql ?: Compiler::_('Model.Sql');
$this->mysqlsettings = $mysqlsettings ?: Compiler::_('Model.Mysqlsettings');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Admin View Data
*
* @param int $id The view ID
*
* @return object|null The view data
* @since 3.2.0
*/
public function get(int $id): ?object
{
if (!isset($this->data[$id]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'b.addfields',
'b.id',
'c.addconditions',
'c.id',
'r.addrelations',
't.tabs'
), array(
'addfields',
'addfields_id',
'addconditions',
'addconditions_id',
'addrelations',
'customtabs'
)
)
);
$query->from('#__componentbuilder_admin_view AS a');
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_admin_fields', 'b')
. ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('b.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_fields_conditions', 'c'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('c.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_fields_relations', 'r'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('r.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_custom_tabs', 't'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('t.admin_view') . ')'
);
$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)
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$view = $this->db->loadObject();
// setup single view code names to use in storing the data
$view->name_single_code = 'oops_hmm_' . $id;
if (isset($view->name_single) && $view->name_single != 'null')
{
$view->name_single_code = StringHelper::safe(
$view->name_single
);
}
// setup list view code name to use in storing the data
$view->name_list_code = 'oops_hmmm_' . $id;
if (isset($view->name_list) && $view->name_list != 'null')
{
$view->name_list_code = StringHelper::safe(
$view->name_list
);
}
// check the length of the view name (+5 for com_ and _)
$name_length = $this->config->component_code_name_length + strlen(
(string) $view->name_single_code
) + 5;
// when the name is larger than 49 we need to add the assets' table name fix
if ($name_length > 49)
{
$this->config->set('add_assets_table_name_fix', true);
}
// setup token check
if (!isset($this->dispenser->hub['token']))
{
$this->dispenser->hub['token'] = [];
}
$this->dispenser->hub['token'][$view->name_single_code] = false;
$this->dispenser->hub['token'][$view->name_list_code] = false;
// set some placeholders
$this->placeholder->set('view', $view->name_single_code);
$this->placeholder->set('views', $view->name_list_code);
$this->placeholder->set('View', StringHelper::safe(
$view->name_single, 'F'
));
$this->placeholder->set('Views', StringHelper::safe(
$view->name_list, 'F'
));
$this->placeholder->set('VIEW', StringHelper::safe(
$view->name_single, 'U'
));
$this->placeholder->set('VIEWS', StringHelper::safe(
$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)
);
unset($placeholders);
// add the tables
$view->addtables = (isset($view->addtables)
&& JsonHelper::check($view->addtables))
? json_decode((string) $view->addtables, true) : null;
if (ArrayHelper::check($view->addtables))
{
$view->tables = array_values($view->addtables);
}
unset($view->addtables);
// set custom tabs
$this->customtabs->set($view);
// set the local tabs
$this->tabs->set($view);
// set permissions
$this->permissions->set($view);
// set fields
$this->fields->set($view);
// build update SQL
$this->history->set($view);
// set the conditions
$this->conditions->set($view);
// set the relations
$this->relations->set($view);
// set linked views
$this->linkedviews->set($view);
// set the lang target
$this->config->lang_target = 'admin';
if ($this->registry->get('builder.site_edit_view.' . $id, false))
{
$this->config->lang_target = 'both';
}
// set javascript
$this->javascript->set($view);
// set css
$this->css->set($view);
// set php
$this->php->set($view);
// set custom buttons
$this->custombuttons->set($view);
// set custom import scripts
$this->customimportscripts->set($view);
// set Ajax for this view
$this->ajax->set($view);
// activate alias builder
$this->customalias->set($view);
// set sql
$this->sql->set($view);
// 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)
);
// clear placeholders
$this->placeholder->remove('view');
$this->placeholder->remove('views');
$this->placeholder->remove('View');
$this->placeholder->remove('Views');
$this->placeholder->remove('VIEW');
$this->placeholder->remove('VIEWS');
// store this view to class object
$this->data[$id] = $view;
}
// return the found view data
return $this->data[$id];
}
}

View File

@ -0,0 +1,265 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Alias;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Alias Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* 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 Registry|null $registry The compiler registry object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Loader|null $load The compiler loader object.
* @param Libraries|null $libraries The compiler libraries model 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,
?Loader $loader = null, ?Libraries $libraries = null,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Data by Alias
*
* @param string $alias The alias name
* @param string $table The table where to find the alias
* @param string $view The view code name
*
* @return array|null The data found with the alias
* @since 3.2.0
*/
public function get(string $alias, string $table, string $view): ?array
{
// if not set, get all keys in table and set by ID
$this->set($table);
// now check if key is found
$name = preg_replace("/[^A-Za-z]/", '', $alias);
if (($id = $this->registry->get('builder.data_with_alias_keys.' . $table . '.' . $name, null)) === null &&
($id = $this->registry->get('builder.data_with_alias_keys.' . $table . '.' . $alias, null)) === null)
{
return null;
}
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_' . $table . ' AS a');
$query->where(
$this->db->quoteName('a.id') . ' = ' . (int) $id
);
// get the row
$this->db->setQuery($query);
$item = $this->db->loadObject();
// get the other target if both
$targets = [$this->config->build_target];
if ($this->config->lang_target === 'both')
{
$targets = ['site', 'admin'];
}
// we load this layout
$php_view = '';
if ($item->add_php_view == 1
&& StringHelper::check($item->php_view))
{
$php_view = $this->gui->set(
$this->customcode->update(base64_decode((string) $item->php_view)),
array(
'table' => $table,
'field' => 'php_view',
'id' => (int) $item->id,
'type' => 'php')
);
}
$content = $this->gui->set(
$this->customcode->update(base64_decode((string) $item->{$table})),
array(
'table' => $table,
'field' => $table,
'id' => (int) $item->id,
'type' => 'html')
);
// load all targets
foreach ($targets as $target)
{
// set libraries
$this->libraries->set($view, $item, $target);
// auto loaders
$this->loader->set($view, $content, $target);
$this->loader->set($view, $php_view, $target);
}
// load uikit version 2 if required
$this->loader->uikit($view, $content);
$this->loader->uikit($view, $php_view);
return [
'id' => $item->id,
'html' => $this->gui->set(
$content,
[
'table' => $table,
'field' => $table,
'id' => $item->id,
'type' => 'html'
]
),
'php_view' => $this->gui->set(
$php_view,
[
'table' => $table,
'field' => 'php_view',
'id' => $item->id,
'type' => 'php'
]
)
];
}
/**
* Load all alias and ID's of a table
*
* @param string $table The table where to find the alias
*
* @return void
* @since 3.2.0
*/
protected function set(string $table)
{
// now check if key is found
if (!$this->registry->get('builder.data_with_alias_keys.' . $table, null))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select(array('a.id', 'a.alias'));
$query->from('#__componentbuilder_' . $table . ' AS a');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
// check if we have an array
if (ArrayHelper::check($items))
{
foreach ($items as $item)
{
// build the key
$k_ey = StringHelper::safe($item->alias);
$key = preg_replace("/[^A-Za-z]/", '', (string) $k_ey);
// set the keys
$this->registry->
set('builder.data_with_alias_keys.' . $table . '.' . $item->alias, $item->id);
$this->registry->
set('builder.data_with_alias_keys.' . $table . '.' . $k_ey, $item->id);
$this->registry->
set('builder.data_with_alias_keys.' . $table . '.' . $key, $item->id);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Component\Data;
use VDM\Joomla\Componentbuilder\Abstraction\BaseRegistry;
/**
* Compiler Component
*
* @since 3.2.0
*/
class Component extends BaseRegistry
{
/**
* Constructor
*
* @param Data|null $component The component data class.
*
* @since 3.2.0
*/
public function __construct(?Data $component = null)
{
$component = $component ?: Compiler::_('Component.Data');
parent::__construct($component->get());
}
/**
* getting any valid value
*
* @param string $path The value's key/path name
*
* @since 3.2.0
*/
public function __get(string $path)
{
// check if it has been set
if (($value = $this->get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
return null;
}
}

View File

@ -0,0 +1,851 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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 Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as ComponentPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Field as Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historycomponent;
use VDM\Joomla\Componentbuilder\Compiler\Model\Whmcs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking;
use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Siteviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customadminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlaplugins;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Compiler Component Data
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Component Placeholder
*
* @var ComponentPlaceholder
* @since 3.2.0
**/
protected ComponentPlaceholder $componentPlaceholder;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Field Unique Name
*
* @var UniqueName
* @since 3.2.0
**/
protected UniqueName $uniqueName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* The modelling component history
*
* @var Historycomponent
* @since 3.2.0
*/
protected Historycomponent $history;
/**
* The modelling whmcs
*
* @var Whmcs
* @since 3.2.0
*/
protected Whmcs $whmcs;
/**
* The modelling Sql Tweaking
*
* @var Sqltweaking
* @since 3.2.0
*/
protected Sqltweaking $sqltweaking;
/**
* The modelling Admin Views
*
* @var Adminviews
* @since 3.2.0
*/
protected Adminviews $adminviews;
/**
* The modelling Site Views
*
* @var Siteviews
* @since 3.2.0
*/
protected Siteviews $siteviews;
/**
* The modelling Custom Admin Views
*
* @var Customadminviews
* @since 3.2.0
*/
protected Customadminviews $customadminviews;
/**
* The modelling Joomla Modules
*
* @var Joomlamodules
* @since 3.2.0
*/
protected Joomlamodules $modules;
/**
* The modelling Joomla Plugins
*
* @var Joomlaplugins
* @since 3.2.0
*/
protected Joomlaplugins $plugins;
/**
* 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 Placeholder|null $placeholder The compiler placeholder object.
* @param ComponentPlaceholder|null $componentPlaceholder The compiler component placeholder object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Field|null $field The compiler field object.
* @param FieldName|null $fieldName The compiler field name object.
* @param UniqueName|null $uniqueName The compiler field unique name object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param Historycomponent|null $history The modelling component history object.
* @param Whmcs|null $whmcs The modelling whmcs object.
* @param Sqltweaking|null $sqltweaking The modelling sql tweaking object.
* @param Adminviews|null $adminviews The modelling adminviews object.
* @param Siteviews|null $siteviews The modelling siteviews object.
* @param Customadminviews|null $customadminviews The modelling customadminviews object.
* @param Joomlamodules|null $modules The modelling modules object.
* @param Joomlaplugins|null $plugins The modelling plugins object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?EventInterface $event = null,
?Placeholder $placeholder = null, ?ComponentPlaceholder $componentPlaceholder = null,
?Dispenser $dispenser = null, ?Customcode $customcode = null, ?Gui $gui = null,
?Field $field = null, ?FieldName $fieldName = null, ?UniqueName $uniqueName = null,
?Filesfolders $filesFolders = null, ?Historycomponent $history = null, ?Whmcs $whmcs = null,
?Sqltweaking $sqltweaking = null, ?Adminviews $adminviews = null, ?Siteviews $siteviews = null,
?Customadminviews $customadminviews = null, ?Joomlamodules $modules = null,
?Joomlaplugins $plugins = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->componentPlaceholder = $componentPlaceholder ?: Compiler::_('Component.Placeholder');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->uniqueName = $uniqueName ?: Compiler::_('Field.Unique.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->history = $history ?: Compiler::_('Model.Historycomponent');
$this->whmcs = $whmcs ?: Compiler::_('Model.Whmcs');
$this->sqltweaking = $sqltweaking ?: Compiler::_('Model.Sqltweaking');
$this->adminviews = $adminviews ?: Compiler::_('Model.Adminviews');
$this->siteviews = $siteviews ?: Compiler::_('Model.Siteviews');
$this->customadminviews = $customadminviews ?: Compiler::_('Model.Customadminviews');
$this->modules = $modules ?: Compiler::_('Model.Joomlamodules');
$this->plugins = $plugins ?: Compiler::_('Model.Joomlaplugins');
$this->db = $db ?: Factory::getDbo();
}
/**
* get current component data
*
* @return object|null The component data
* @since 3.2.0
*/
public function get(): ?object
{
// Create a new query object.
$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'
);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array_keys($selection), array_values($selection)
)
);
// from this table
$query->from('#__componentbuilder_joomla_component AS a');
// jointer-map
$joiners = array(
'b' => 'component_admin_views',
'c' => 'component_site_views',
'd' => 'component_custom_admin_views',
'e' => 'component_updates',
'f' => 'component_mysql_tweaks',
'g' => 'component_custom_admin_menus',
'h' => 'component_config',
'i' => 'component_dashboard',
'j' => 'component_files_folders',
'l' => 'component_plugins',
'k' => 'component_modules'
);
// load the joins
foreach ($joiners as $as => $join)
{
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_' . $join, $as)
. ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName($as . '.joomla_component') . ')'
);
}
$query->where(
$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)
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects
$component = $this->db->loadObject();
// make sure we got a component loaded
if (!is_object($component) || !isset($component->system_name))
{
return null;
}
// Trigger Event: jcb_ce_onBeforeModelComponentData
$this->event->trigger(
'jcb_ce_onBeforeModelComponentData',
array(&$component_context, &$component)
);
// load the global placeholders
$this->placeholder->active = $this->componentPlaceholder->get();
// set component sales name
$component->sales_name = StringHelper::safe(
$component->system_name
);
// set the component name_code
$component->name_code = StringHelper::safe(
$component->name_code
);
// ensure version naming is correct
$this->config->set('component_version', preg_replace(
'/[^0-9.]+/', '', (string) $component->component_version
)
);
// set the website and autor for global use (default to VDM if not found)
$this->config->set('project_website', $component->website ?? 'https://dev.vdm.io');
$this->config->set('project_author', $component->author ?? 'VDM');
// set the files and folders
$this->filesFolders->set($component);
// set the uikit switch
$this->config->set('uikit', $component->adduikit);
// set whmcs links if needed
$this->whmcs->set($component);
// set the footable switch
if ($component->addfootable)
{
// force add footable
$this->config->set('footable ', true);
// add the version
$this->config->set('footable_version', (3 == $component->addfootable) ? 3 : 2);
}
// set the addcustommenus data
$component->addcustommenus = (isset($component->addcustommenus)
&& JsonHelper::check($component->addcustommenus))
? json_decode((string) $component->addcustommenus, true) : null;
if (ArrayHelper::check($component->addcustommenus))
{
$component->custommenus = array_values($component->addcustommenus);
}
unset($component->addcustommenus);
// set the sql tweak data
$this->sqltweaking->set($component);
// set the admin view data
$this->adminviews->set($component);
// set the site view data
$this->siteviews->set($component);
// set the custom_admin_views data
$this->customadminviews->set($component);
// set the config data
$component->addconfig = (isset($component->addconfig)
&& JsonHelper::check($component->addconfig))
? json_decode((string) $component->addconfig, true) : null;
if (ArrayHelper::check($component->addconfig))
{
$component->config = array_map(
function ($field) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set($field);
// set unique name counter
$this->uniqueName->set($field['base_name'], 'configs');
// return field
return $field;
}, array_values($component->addconfig)
);
// do some house cleaning (for fields)
foreach ($component->config as $field)
{
// so first we lock the field name in
$this->fieldName->get($field, 'configs');
}
// unset original value
unset($component->addconfig);
}
// set the add contributors
$component->addcontributors = (isset($component->addcontributors)
&& JsonHelper::check($component->addcontributors))
? json_decode((string) $component->addcontributors, true) : null;
if (ArrayHelper::check($component->addcontributors))
{
$this->config->set('add_contributors', true);
$component->contributors = array_values(
$component->addcontributors
);
}
unset($component->addcontributors);
// set the version updates
$component->version_update = (isset($component->version_update)
&& JsonHelper::check($component->version_update))
? json_decode((string) $component->version_update, true) : null;
if (ArrayHelper::check($component->version_update))
{
$component->version_update = array_values(
$component->version_update
);
}
// build update SQL
$this->history->set($component);
// set GUI mapper
$guiMapper = [
'table' => 'joomla_component',
'id' => (int) $this->config->component_id,
'field' => 'javascript',
'type' => 'js'
];
// add_javascript
if ($component->add_javascript == 1)
{
$this->dispenser->set(
$component->javascript,
'component_js',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_js'] = '';
}
unset($component->javascript);
// add global CSS
$addGlobalCss = ['admin', 'site'];
foreach ($addGlobalCss as $area)
{
// add_css if found
if (isset($component->{'add_css_' . $area})
&& $component->{'add_css_' . $area} == 1
&& isset($component->{'css_' . $area})
&& StringHelper::check(
$component->{'css_' . $area}
))
{
$this->dispenser->set(
$component->{'css_' . $area},
'component_css_' . $area
);
}
else
{
$this->dispenser->hub['component_css_' . $area] = '';
}
unset($component->{'css_' . $area});
}
// set the lang target
$this->config->lang_target = 'admin';
// add PHP in ADMIN
$addScriptMethods = [
'php_preflight',
'php_postflight',
'php_method'
];
$addScriptTypes = [
'install',
'update',
'uninstall'
];
// update GUI mapper
$guiMapper['type'] = 'php';
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset(
$component->{'add_' . $scriptMethod . '_' . $scriptType}
)
&& $component->{'add_' . $scriptMethod . '_' . $scriptType}
== 1
&& StringHelper::check(
$component->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' . $scriptType;
$this->dispenser->set(
$component->{$scriptMethod . '_' . $scriptType},
$scriptMethod,
$scriptType,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub[$scriptMethod][$scriptType] = '';
}
unset($component->{$scriptMethod . '_' . $scriptType});
}
}
// add_php_helper
if ($component->add_php_helper_admin == 1
&& StringHelper::check(
$component->php_helper_admin
))
{
$this->config->lang_target = 'admin';
// update GUI mapper
$guiMapper['field'] = 'php_helper_admin';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_admin,
'component_php_helper_admin',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_admin'] = '';
}
unset($component->php_helper);
// add_admin_event
if ($component->add_admin_event == 1
&& StringHelper::check($component->php_admin_event))
{
$this->config->lang_target = 'admin';
// update GUI mapper field
$guiMapper['field'] = 'php_admin_event';
$this->dispenser->set(
$component->php_admin_event,
'component_php_admin_event',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_php_admin_event'] = '';
}
unset($component->php_admin_event);
// add_php_helper_both
if ($component->add_php_helper_both == 1
&& StringHelper::check($component->php_helper_both))
{
$this->config->lang_target = 'both';
// update GUI mapper field
$guiMapper['field'] = 'php_helper_both';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_both,
'component_php_helper_both',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_both'] = '';
}
// add_php_helper_site
if ($component->add_php_helper_site == 1
&& StringHelper::check($component->php_helper_site))
{
$this->config->lang_target = 'site';
// update GUI mapper field
$guiMapper['field'] = 'php_helper_site';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_site,
'component_php_helper_site',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_site'] = '';
}
unset($component->php_helper);
// add_site_event
if ($component->add_site_event == 1
&& StringHelper::check($component->php_site_event))
{
$this->config->lang_target = 'site';
// update GUI mapper field
$guiMapper['field'] = 'php_site_event';
$this->dispenser->set(
$component->php_site_event,
'component_php_site_event',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_php_site_event'] = '';
}
unset($component->php_site_event);
// add_sql
if ($component->add_sql == 1)
{
$this->dispenser->set(
$component->sql,
'sql',
'component_sql'
);
}
unset($component->sql);
// add_sql_uninstall
if ($component->add_sql_uninstall == 1)
{
$this->dispenser->set(
$component->sql_uninstall,
'sql_uninstall'
);
}
unset($component->sql_uninstall);
// bom
if (StringHelper::check($component->bom))
{
$this->config->set('bom_path',
$this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' . $component->bom
);
}
unset($component->bom);
// README
$component->readme =
$component->addreadme ?
$this->customcode->update(
base64_decode((string) $component->readme)
) : '';
// set lang now
$nowLang = $this->config->lang_target;
$this->config->lang_target = 'admin';
// dashboard methods
$component->dashboard_tab = (isset($component->dashboard_tab)
&& JsonHelper::check($component->dashboard_tab))
? json_decode((string) $component->dashboard_tab, true) : null;
if (ArrayHelper::check($component->dashboard_tab))
{
$component->dashboard_tab = array_map(
function ($array) {
$array['html'] = $this->customcode->update($array['html']);
return $array;
}, array_values($component->dashboard_tab)
);
}
else
{
$component->dashboard_tab = '';
}
// add the php of the dashboard if set
if (isset($component->php_dashboard_methods)
&& StringHelper::check(
$component->php_dashboard_methods
))
{
// load the php for the dashboard model
$component->php_dashboard_methods = $this->gui->set(
$this->customcode->update(
base64_decode((string) $component->php_dashboard_methods)
),
[
'table' => 'component_dashboard',
'field' => 'php_dashboard_methods',
'id' => (int) $component->component_dashboard_id,
'type' => 'php'
]
);
}
else
{
$component->php_dashboard_methods = '';
}
// reset back to now lang
$this->config->lang_target = $nowLang;
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array('update_server', 'sales_server');
foreach ($serverArray as $server)
{
if ($component->{'add_' . $server} == 1
&& is_numeric(
$component->{$server}
)
&& $component->{$server} > 0)
{
// get the server protocol
$component->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $component->{$server}, 'id', 'protocol'
);
}
else
{
$component->{$server} = 0;
// only change this for sales server (update server can be added loacaly to the zip file)
if ('sales_server' === $server)
{
$component->{'add_' . $server} = 0;
}
$component->{$server . '_protocol'} = 0;
}
}
// set the ignore folders for repo if found
if (isset($component->toignore)
&& StringHelper::check(
$component->toignore
))
{
if (strpos((string) $component->toignore, ',') !== false)
{
$component->toignore = array_map(
'trim', (array) explode(',', (string) $component->toignore)
);
}
else
{
$component->toignore = array(trim((string) $component->toignore));
}
}
else
{
// the default is to ignore the repo folder
$component->toignore = array('.git');
}
// set all modules
$this->modules->set($component);
// set all plugins
$this->plugins->set($component);
// Trigger Event: jcb_ce_onAfterModelComponentData
$this->event->trigger(
'jcb_ce_onAfterModelComponentData',
array(&$component_context, &$component)
);
// return found component data
return $component;
}
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -88,7 +88,7 @@ class Placeholder implements PlaceholderInterface
// load the db
$db = $this->db;
// reset bucket
$bucket = array();
$bucket = [];
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.target', 'a.value')));
@ -105,7 +105,7 @@ class Placeholder implements PlaceholderInterface
// open all the code
foreach ($bucket as $key => &$code)
{
$code = base64_decode($code);
$code = base64_decode((string) $code);
}
}
@ -126,7 +126,7 @@ class Placeholder implements PlaceholderInterface
)) !== false
&& JsonHelper::check($_placeholders))
{
$_placeholders = json_decode($_placeholders, true);
$_placeholders = json_decode((string) $_placeholders, true);
if (ArrayHelper::check($_placeholders))
{
foreach ($_placeholders as $row)

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -12,6 +12,8 @@
namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
@ -20,10 +22,85 @@ use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls: $this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; // be warned!
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
* @param Registry|null $config The Joomla configuration
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get add contributors switch
*
* @return bool Add contributors switch
* @since 3.2.0
*/
protected function getAddcontributors(): bool
{
return false; // default is false
}
/**
* get Add Ajax Switch
*
* @return bool Add Ajax Switch
* @since 3.2.0
*/
protected function getAddajax(): bool
{
return false; // default is false
}
/**
* get Add Site Ajax Switch
*
* @return bool Add Site Ajax Switch
* @since 3.2.0
*/
protected function getAddsiteajax(): bool
{
return false; // default is false
}
/**
* get add eximport
*
* @return bool add eximport switch
* @since 3.2.0
*/
protected function getAddeximport(): bool
{
return false; // default is false
}
/**
* get posted component id
*
@ -35,6 +112,17 @@ class Config extends BaseConfig
return $this->input->post->get('component_id', 0, 'INT');
}
/**
* get component version
*
* @return string Component version
* @since 3.2.0
*/
protected function getComponentversion(): string
{
return '1.0.0';
}
/**
* get components code name
*
@ -70,7 +158,7 @@ class Config extends BaseConfig
protected function getComponentcodenamelength(): int
{
// get component name length
return strlen($this->component_code_name);
return strlen((string) $this->component_code_name);
}
/**
@ -84,6 +172,20 @@ class Config extends BaseConfig
return $this->input->post->get('joomla_version', 3, 'INT');
}
/**
* get Joomla versions
*
* @return array Joomla versions
* @since 3.2.0
*/
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
];
}
/**
* get posted Joomla version name
*
@ -95,6 +197,17 @@ class Config extends BaseConfig
return StringHelper::safe($this->joomla_version);
}
/**
* set joomla fields
*
* @return bool set joomla fields
* @since 3.2.0
*/
protected function getSetjoomlafields(): bool
{
return false;
}
/**
* get indentation value
*
@ -138,15 +251,12 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('debug_line_nr', 2, 'INT');
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'debug_linenr' ) == 1) ? true : false
)
);
return $add;
// get global value
if ($value > 1)
{
return (int) GetHelper::var('joomla_component', $this->component_id, 'id', 'debug_linenr');
}
return $value;
}
/**
@ -157,12 +267,11 @@ class Config extends BaseConfig
*/
protected function getMinify(): int
{
// get posted value
$minify = $this->input->post->get('minify', 2, 'INT');
// if value is 2 use global value
$minify = ($minify != 2) ? $minify : $this->params->get('minify', 0);
return $minify;
return ($minify != 2) ? $minify : $this->params->get('minify', 0);
}
/**
@ -173,16 +282,14 @@ class Config extends BaseConfig
*/
protected function getRemovelinebreaks(): bool
{
$value = 2; // 2 is global (use the components value) TODO: get from post
// get active value
$remove = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'remove_line_breaks' ) == 1) ? true : false
)
);
return $remove;
// get posted value
$value = $this->input->post->get('remove_line_breaks', 2, 'INT');
// get global
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'remove_line_breaks');
}
return (bool) $value;
}
/**
@ -197,6 +304,30 @@ class Config extends BaseConfig
return \extension_loaded('Tidy');
}
/**
* add tidy warning
*
* @return bool Set tidy warning
* @since 3.2.0
*/
protected function getSettidywarning(): bool
{
// add warning once
return true;
}
/**
* get history tag switch
*
* @return bool get history tag switch
* @since 3.2.0
*/
protected function getSettaghistory(): bool
{
// add warning once
return true;
}
/**
* get language tag
*
@ -206,7 +337,7 @@ class Config extends BaseConfig
protected function getLangtag(): string
{
// get the global language
return $this->params->get('language', 'en-GB');
return $this->params->get('language', 'en-GB');
}
/**
@ -275,11 +406,36 @@ class Config extends BaseConfig
protected function getFieldbuildertype(): int
{
// get the field type builder
return $this->params->get(
return $this->params->get(
'compiler_field_builder_type', 2
);
}
/**
* get default fields
*
* @return array The default fields
* @since 3.2.0
*/
protected function getDefaultfields(): array
{
// get the field type builder
return ['created', 'created_by', 'modified', 'modified_by', 'published',
'ordering', 'access', 'version', 'hits', 'id'];
}
/**
* get temporary path
*
* @return string The temporary path
* @since 3.2.0
*/
protected function getTmppath(): string
{
// get the temporary path
return $this->config->get('tmp_path');
}
/**
* get compiler path
*
@ -289,7 +445,7 @@ class Config extends BaseConfig
protected function getCompilerpath(): string
{
// get the compiler path
return $this->params->get(
return $this->params->get(
'compiler_folder_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler'
);
@ -304,7 +460,34 @@ class Config extends BaseConfig
protected function getJcbpowerspath(): string
{
// get jcb powers path
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
}
/**
* get bom path
*
* @return string The bom path
* @since 3.2.0
*/
protected function getBompath(): string
{
// get default bom path
return $this->compiler_path . '/default.txt';
}
/**
* get custom folder path
*
* @return string The custom folder path
* @since 3.2.0
*/
protected function getCustomfolderpath(): string
{
// get the custom folder path
return $this->params->get(
'custom_folder_path',
JPATH_COMPONENT_ADMINISTRATOR . '/custom'
);
}
/**
@ -321,12 +504,50 @@ class Config extends BaseConfig
);
// get component value
$add = (($add_assets_table_fix = (int) GetHelper::var(
return (($add_assets_table_fix = (int) GetHelper::var(
'joomla_component', $this->component_id, 'id',
'assets_table_fix'
)) == 3) ? $global : $add_assets_table_fix;
}
return $add;
/**
* get switch to add assets table name fix
*
* @return bool Switch number to add assets table name fix
* @since 3.2.0
*/
protected function getAddassetstablenamefix(): bool
{
// get global is false
return false;
}
/**
* get access worse case size
*
* @return int access worse case size
* @since 3.2.0
*/
protected function getAccessworsecase(): int
{
// we start at zero
return 0;
}
/**
* get mysql table keys
*
* @return array
* @since 3.2.0
*/
protected function getMysqltablekeys(): array
{
return [
'engine' => ['default' => 'MyISAM'],
'charset' => ['default' => 'utf8'],
'collate' => ['default' => 'utf8_general_ci'],
'row_format' => ['default' => '']
];
}
/**
@ -339,15 +560,12 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('add_placeholders', 2, 'INT');
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders' ) == 1) ? true : false
)
);
return $add;
// get global value
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders');
}
return (bool) $value;
}
/**
@ -360,15 +578,12 @@ class Config extends BaseConfig
{
// get posted value
$value = $this->input->post->get('powers', 2, 'INT');
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers' ) == 1) ? true : false
)
);
return $add;
// get global value
if ($value > 1)
{
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers');
}
return (bool) $value;
}
/**
@ -384,6 +599,17 @@ class Config extends BaseConfig
return 'admin';
}
/**
* get encryption types
*
* @return array encryption types
* @since 3.2.0
*/
protected function getCryptiontypes(): array
{
return ['basic', 'medium', 'whmcs', 'expert'];
}
/**
* get basic encryption switch
*
@ -416,6 +642,72 @@ class Config extends BaseConfig
{
return false;
}
/**
* Should we remove the site folder
*
* @return bool Switch to control the removal
* @since 3.2.0
*/
protected function getRemovesitefolder(): bool
{
return false;
}
/**
* Should we remove the site edit folder
*
* @return bool Switch to control the removal
* @since 3.2.0
*/
protected function getRemovesiteeditfolder(): bool
{
return true;
}
/**
* The Uikit switch
*
* @return int Switch to control the adding uikit
* @since 3.2.0
*/
protected function getUikit(): int
{
return 0; // default its not added
}
/**
* The google chart switch
*
* @return bool Switch to control the adding googlechart
* @since 3.2.0
*/
protected function getGooglechart(): bool
{
return false; // default its not added
}
/**
* The footable switch
*
* @return bool Switch to control the adding footable
* @since 3.2.0
*/
protected function getFootable(): bool
{
return false; // default its not added
}
/**
* The footable version
*
* @return int Switch to control the adding footable
* @since 3.2.0
*/
protected function getFootableversion(): int
{
return 2; // default is version 2
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Interfaces\Mapperdoubleinterface;
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
use VDM\Joomla\Componentbuilder\Abstraction\Mapper;
/**
* Compiler Content
*
* @since 3.2.0
*/
class Content extends Mapper implements Mapperdoubleinterface, Mappersingleinterface
{
/**
* Model the key
*
* @param string $key The key to model
*
* @return string
* @since 3.2.0
*/
protected function key(string $key): string
{
return Placefix::_h($key);
}
/**
* Model the first key
*
* @param string $key The first key to model
*
* @return string
* @since 3.2.0
*/
protected function firstKey(string $key): string
{
return $key;
}
/**
* Model the second key
*
* @param string $key The second key to model
*
* @return string
* @since 3.2.0
*/
protected function secondKey(string $key): string
{
return Placefix::_h($key);
}
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -193,7 +193,7 @@ class Customcode implements CustomcodeInterface
var_dump($string);
}
// the ids found in this content
$bucket = array();
$bucket = [];
$found = GetHelper::allBetween(
$string, '[CUSTO' . 'MCODE=', ']'
);
@ -213,9 +213,9 @@ class Customcode implements CustomcodeInterface
$id = (int) $key;
}
elseif (StringHelper::check($key)
&& strpos($key, '+') === false)
&& strpos((string) $key, '+') === false)
{
$getFuncName = trim($key);
$getFuncName = trim((string) $key);
if (!isset($this->functionNameMemory[$getFuncName]))
{
if (!$found_local = GetHelper::var(
@ -232,10 +232,10 @@ class Customcode implements CustomcodeInterface
}
elseif (StringHelper::check($key)
&& strpos(
$key, '+'
(string) $key, '+'
) !== false)
{
$array = explode('+', $key);
$array = explode('+', (string) $key);
// set ID
if (is_numeric($array[0]))
{
@ -268,7 +268,7 @@ class Customcode implements CustomcodeInterface
{
if (!isset($this->data[$id]['args']))
{
$this->data[$id]['args'] = array();
$this->data[$id]['args'] = [];
}
// only load if not already loaded
if (!isset($this->data[$id]['args'][$key]))
@ -278,20 +278,18 @@ class Customcode implements CustomcodeInterface
// update the function values with the custom code key placeholders (this allow the use of [] + and , in the values)
$this->data[$id]['args'][$key]
= array_map(
function ($_key) {
return $this->placeholder->update(
fn($_key) => $this->placeholder->update(
$_key,
$this->keys
);
}, (array) explode(',', $array[1])
);
), (array) explode(',', $array[1])
);
}
elseif (StringHelper::check(
$array[1]
))
{
$this->data[$id]['args'][$key]
= array();
= [];
// update the function values with the custom code key placeholders (this allow the use of [] + and , in the values)
$this->data[$id]['args'][$key][]
= $this->placeholder->update(
@ -417,7 +415,7 @@ class Customcode implements CustomcodeInterface
$this->db->quoteName('a.from_line') . ' ASC'
); // <--- insure we always add code from top of file
// reset custom code
$this->active = array();
$this->active = [];
}
$query->where($this->db->quoteName('a.published') . ' >= 1');
$this->db->setQuery($query);
@ -428,7 +426,7 @@ class Customcode implements CustomcodeInterface
// open the code
foreach ($bucket as $nr => &$customCode)
{
$customCode['code'] = base64_decode($customCode['code']);
$customCode['code'] = base64_decode((string) $customCode['code']);
// always insure that the external code is loaded
$customCode['code'] = $this->external->set(
$customCode['code']
@ -453,14 +451,14 @@ class Customcode implements CustomcodeInterface
if (isset($customCode['hashtarget']))
{
$customCode['hashtarget'] = explode(
"__", $customCode['hashtarget']
"__", (string) $customCode['hashtarget']
);
// is this a replace code, set end has array
if ($customCode['type'] == 1
&& strpos($customCode['hashendtarget'], '__') !== false)
&& strpos((string) $customCode['hashendtarget'], '__') !== false)
{
$customCode['hashendtarget'] = explode(
"__", $customCode['hashendtarget']
"__", (string) $customCode['hashendtarget']
);
// NOW see if this is an end of page target (TODO not sure if the string is always d41d8cd98f00b204e9800998ecf8427e)
@ -504,7 +502,7 @@ class Customcode implements CustomcodeInterface
*/
protected function insert(array $ids, string $string, int $debug = 0): string
{
$code = array();
$code = [];
// load the code
foreach ($ids as $id)
{
@ -564,8 +562,8 @@ class Customcode implements CustomcodeInterface
var_dump($this->placeholder->active);
}
$code['[CUSTOM' . 'CODE=' . $key . ']'] = $placeholder['start']
. PHP_EOL . $this->placeholder->update(
$item['code'], $this->placeholder->active
. PHP_EOL . $this->placeholder->update_(
$item['code']
) . $placeholder['end'];
}
// always clear the args
@ -581,9 +579,9 @@ class Customcode implements CustomcodeInterface
}
// check what type of place holders we should load here
$placeholderType = (int) $item['comment_type'] . '2';
if (stripos($item['code'], Placefix::b() . 'view') !== false
|| stripos($item['code'], Placefix::b() . 'sview') !== false
|| stripos($item['code'], Placefix::b() . 'arg') !== false)
if (stripos((string) $item['code'], Placefix::b() . 'view') !== false
|| stripos((string) $item['code'], Placefix::b() . 'sview') !== false
|| stripos((string) $item['code'], Placefix::b() . 'arg') !== false)
{
// if view is being set dynamicly then we can't update this code via IDE (TODO)
$placeholderType = 3;
@ -596,8 +594,8 @@ class Customcode implements CustomcodeInterface
);
$code['[CUSTOM' . 'CODE=' . $keyPlaceholder . ']']
= $placeholder['start'] . PHP_EOL
. $this->placeholder->update(
$item['code'], $this->placeholder->active
. $this->placeholder->update_(
$item['code']
) . $placeholder['end'];
}
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -117,7 +117,7 @@ class Dispenser implements DispenserInterface
* @since 3.2.0
*/
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add = false): bool
{
// only load if we have a string
if (!StringHelper::check($script))
@ -132,7 +132,7 @@ class Dispenser implements DispenserInterface
// check if the script first key is set
if ($second && !isset($this->hub[$first]))
{
$this->hub[$first] = array();
$this->hub[$first] = [];
}
elseif ($add && !$second
&& !isset($this->hub[$first]))
@ -143,7 +143,7 @@ class Dispenser implements DispenserInterface
if ($second && $third
&& !isset($this->hub[$first][$second]))
{
$this->hub[$first][$second] = array();
$this->hub[$first][$second] = [];
}
elseif ($add && $second && !$third
&& !isset($this->hub[$first][$second]))
@ -263,7 +263,7 @@ class Dispenser implements DispenserInterface
$script .= $prefix . str_replace(
array_keys($this->placeholder->active),
array_values($this->placeholder->active),
$this->hub[$first][$second]
(string) $this->hub[$first][$second]
) . $suffix;
// clear some memory
if ($unset)

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -122,7 +122,7 @@ class External implements ExternalInterface
var_dump($string);
}
// target content
$bucket = array();
$bucket = [];
$found = GetHelper::allBetween(
$string, '[EXTERNA' . 'LCODE=', ']'
);
@ -135,18 +135,18 @@ class External implements ExternalInterface
// example: >{3|4
// will cut 3 rows at top and 4 rows at bottom
// if the external code has 8 or more lines
if (($pos = strpos($target, '>{')) !== false)
if (($pos = strpos((string) $target, '>{')) !== false)
{
// the length
$target_len = strlen($target);
$target_len = strlen((string) $target);
// where to cut
$cutting = $target_len - $pos;
// get the sequence
$sequence = substr($target, "-$cutting");
$sequence = substr((string) $target, "-$cutting");
// remove from the URL
$target_url = str_replace($sequence, '', $target);
$target_url = str_replace($sequence, '', (string) $target);
// set the cut key for this target if not set
$this->cutter[trim($target)] = str_replace('>{', '', $sequence);
$this->cutter[trim((string) $target)] = str_replace('>{', '', $sequence);
}
else
{
@ -342,17 +342,9 @@ class External implements ExternalInterface
);
}
}
// add to local bucket
if (isset($this->code[$target_key]))
{
// update the placeholder with the external code string
$bucket[$key] = $this->code[$target_key];
}
else
{
// remove the placeholder
$bucket[$key] = '';
}
$bucket[$key] = $this->code[$target_key] ?? '';
}
/**

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -327,16 +327,8 @@ class Extractor implements ExtractorInterface
// make sure we have the path correct (the script file is not in admin path for example)
// there may be more... will nead to keep our eye on this... since files could be moved during install
$file = str_replace('./', '', $file); # TODO (windows path issues)
if ($file !== 'script.php')
{
$path = $target . '/' . $file;
}
else
{
$path = $file;
}
$file = str_replace('./', '', (string) $file); # TODO (windows path issues)
$path = $file !== 'script.php' ? $target . '/' . $file : $file;
// now we go line by line
foreach (new \SplFileObject($file) as $lineNumber => $lineContent)
@ -366,10 +358,10 @@ class Extractor implements ExtractorInterface
// check if the ending placeholder was found
if (isset($reading[$targetKey]) && $reading[$targetKey]
&& ((trim($lineContent) === $end
|| strpos($lineContent, $end) !== false)
|| (trim($lineContent) === $endHTML
|| strpos($lineContent, $endHTML) !== false)))
&& ((trim((string) $lineContent) === $end
|| strpos((string) $lineContent, $end) !== false)
|| (trim((string) $lineContent) === $endHTML
|| strpos((string) $lineContent, $endHTML) !== false)))
{
// trim the placeholder and if there is still data then load it
if (isset($endReplace)
@ -411,7 +403,7 @@ class Extractor implements ExtractorInterface
$this->new[$pointer[$targetKey]][]
= $this->db->quote(
base64_encode($c0de)
base64_encode((string) $c0de)
); // 'code'
if ($_type == 2)
@ -438,7 +430,7 @@ class Extractor implements ExtractorInterface
$this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('code') . ' = '
. $this->db->quote(base64_encode($c0de));
. $this->db->quote(base64_encode((string) $c0de));
if ($_type == 2)
{
@ -490,8 +482,8 @@ class Extractor implements ExtractorInterface
// see if the custom code line starts now with PHP/JS comment type
if ((!isset($reading[$targetKey]) || !$reading[$targetKey])
&& (($i === 1 && trim($lineContent) === $start)
|| strpos($lineContent, $start) !== false))
&& (($i === 1 && trim((string) $lineContent) === $start)
|| strpos((string) $lineContent, $start) !== false))
{
$commentType = 1; // PHP/JS type
$startReplace = $start;
@ -500,8 +492,8 @@ class Extractor implements ExtractorInterface
// see if the custom code line starts now with HTML comment type
elseif ((!isset($reading[$targetKey])
|| !$reading[$targetKey])
&& (($i === 1 && trim($lineContent) === $startHTML)
|| strpos($lineContent, $startHTML) !== false))
&& (($i === 1 && trim((string) $lineContent) === $startHTML)
|| strpos((string) $lineContent, $startHTML) !== false))
{
$commentType = 2; // HTML type
$startReplace = $startHTML;
@ -512,7 +504,7 @@ class Extractor implements ExtractorInterface
if ($commentType > 0)
{
// if we have all on one line we have a problem (don't load it TODO)
if (strpos($lineContent, $endReplace) !== false)
if (strpos((string) $lineContent, (string) $endReplace) !== false)
{
// reset found comment type
$commentType = 0;

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -130,7 +130,7 @@ class Paths
protected function load()
{
// set the local paths to search
$local_paths = array();
$local_paths = [];
// admin path
$local_paths['admin'] = JPATH_ADMINISTRATOR . '/components/com_'
@ -158,7 +158,7 @@ class Paths
if (($path = $this->getModulePath($module_id)) !== false)
{
// set the path
$local_paths['module_' . str_replace('/', '_', $path)] = $path;
$local_paths['module_' . str_replace('/', '_', (string) $path)] = $path;
}
}
}
@ -172,7 +172,7 @@ class Paths
if (($path = $this->getPluginPath($plugin_id)) !== false)
{
// set the path
$local_paths['plugin_' . str_replace('/', '_', $path)] = JPATH_ROOT . '/plugins/' . $path;
$local_paths['plugin_' . str_replace('/', '_', (string) $path)] = JPATH_ROOT . '/plugins/' . $path;
}
}
}
@ -207,28 +207,20 @@ class Paths
{
$addjoomla_modules = (JsonHelper::check(
$addjoomla_modules
)) ? json_decode($addjoomla_modules, true) : null;
)) ? json_decode((string) $addjoomla_modules, true) : null;
if (ArrayHelper::check($addjoomla_modules))
{
$joomla_modules = array_filter(
array_values($addjoomla_modules),
function ($array) {
// only load the modules whose target association call for it
if (!isset($array['target']) || $array['target'] != 2)
{
return true;
}
return false;
}
// only load the modules whose target association call for it
fn($array): bool => !isset($array['target']) || $array['target'] != 2
);
// if we have values we return IDs
if (ArrayHelper::check($joomla_modules))
{
return array_map(
function ($array) {
return (int) $array['module'];
}, $joomla_modules
fn($array) => (int) $array['module'], $joomla_modules
);
}
}
@ -283,7 +275,7 @@ class Paths
$module->name
);
// set module folder name
$module->folder_name = 'mod_' . strtolower($module->code_name);
$module->folder_name = 'mod_' . strtolower((string) $module->code_name);
// set the lang key
$this->extractor->langKeys[strtoupper($module->folder_name)] =
@ -322,7 +314,8 @@ class Paths
{
$addjoomla_plugins = (JsonHelper::check(
$addjoomla_plugins
)) ? json_decode($addjoomla_plugins, true) : null;
)) ? json_decode((string) $addjoomla_plugins, true) : null;
if (ArrayHelper::check($addjoomla_plugins))
{
$joomla_plugins = array_filter(
@ -341,9 +334,7 @@ class Paths
if (ArrayHelper::check($joomla_plugins))
{
return array_map(
function ($array) {
return (int) $array['plugin'];
}, $joomla_plugins
fn($array) => (int) $array['plugin'], $joomla_plugins
);
}
}
@ -408,9 +399,9 @@ class Paths
);
// set plugin folder name
$plugin->group = strtolower($plugin->group);
$plugin->group = strtolower((string) $plugin->group);
// set plugin file name
$plugin->file_name = strtolower($plugin->code_name);
$plugin->file_name = strtolower((string) $plugin->code_name);
// set the lang key
$this->extractor->langKeys['PLG_' . strtoupper(

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -136,7 +136,7 @@ class Gui implements GuiInterface
$config['prefix'] = PHP_EOL;
}
// add placeholder based on type of code
switch (strtolower($config['type']))
switch (strtolower((string) $config['type']))
{
// adding with html commenting
case 'html':
@ -183,7 +183,7 @@ class Gui implements GuiInterface
// get file content
$file_conent = FileHelper::getContent($file);
$guiCode = array();
$guiCode = [];
// we add a new search for the GUI CODE Blocks
$guiCode[] = GetHelper::allBetween(
$file_conent, '/***[JCB' . 'GUI<>', '/***[/JCBGUI' . '$$$$]***/'
@ -204,7 +204,7 @@ class Gui implements GuiInterface
if (is_array($query) && count($query) >= 3)
{
// cleanup the newlines around the code
$code = trim(str_replace($first_line, '', $code), PHP_EOL)
$code = trim(str_replace($first_line, '', (string) $code), PHP_EOL)
. PHP_EOL;
// set the ID
$id = (int) $query[2];
@ -220,7 +220,7 @@ class Gui implements GuiInterface
$object = new \stdClass();
$object->id = $id;
$object->{$field} = base64_encode(
$code
(string) $code
); // (TODO) this may not always work...
// update the value in GUI
$this->db->updateObject(
@ -243,14 +243,9 @@ class Gui implements GuiInterface
protected function check(string &$code): bool
{
// check for customcode placeholders
if (strpos($code, '$$$$') !== false)
{
// we do not add GUI wrapper placeholder to code
// that already has any customcode placeholders
return false;
}
return true;
// we do not add GUI wrapper placeholder to code
// that already has any customcode placeholders
return strpos($code, '$$$$') === false;
}
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -56,31 +56,31 @@ class Hash
public function set(string $script): string
{
// check if we should hash a string
if (\strpos($script, 'HASH' . 'STRING((((') !== false)
if (strpos($script, 'HASH' . 'STRING((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'HASH' . 'STRING((((', '))))'
);
$locker = array();
$locker = [];
// convert them
foreach ($values as $value)
{
$locker['HASH' . 'STRING((((' . $value . '))))']
= \md5($value);
= md5((string) $value);
}
// update the script
return $this->placeholder->update($script, $locker);
}
// check if we should hash a file
if (\strpos($script, 'HASH' . 'FILE((((') !== false)
if (strpos($script, 'HASH' . 'FILE((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'HASH' . 'FILE((((', '))))'
);
$locker = array();
$locker = [];
// convert them
foreach ($values as $path)
{
@ -89,7 +89,7 @@ class Hash
{
// now we hash the file content
$locker['HASH' . 'FILE((((' . $path . '))))']
= \md5($value);
= md5((string) $value);
}
else
{

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -62,15 +62,15 @@ class LockBase implements LockBaseInterface
$values = GetHelper::allBetween(
$script, 'LOCK'.'BASE64((((', '))))'
);
$locker = array();
$locker = [];
// convert them
foreach ($values as $value)
{
$locker['LOCK'.'BASE64((((' . $value . '))))']
= "base64_decode( preg_replace('/\s+/', ''," .
PHP_EOL . Indent::_(2) . "'" .
\wordwrap(
\base64_encode($value), 64, PHP_EOL . Indent::_(2), true
wordwrap(
base64_encode((string) $value), 64, PHP_EOL . Indent::_(2), true
) .
"'))";
}

View File

@ -0,0 +1,341 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Customview;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Csscustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin Custom View Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Admin views
*
* @var array
* @since 3.2.0
*/
protected array $data;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Compiler Template Layout
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Compiler Dynamic Get Data
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* The modelling javascript
*
* @var Javascriptcustomview
* @since 3.2.0
*/
protected Javascriptcustomview $javascript;
/**
* The modelling css
*
* @var Csscustomview
* @since 3.2.0
*/
protected Csscustomview $css;
/**
* The modelling php admin view
*
* @var Phpcustomview
* @since 3.2.0
*/
protected Phpcustomview $php;
/**
* The modelling custom buttons
*
* @var Custombuttons
* @since 3.2.0
*/
protected Custombuttons $custombuttons;
/**
* The modelling ajax
*
* @var Ajaxcustomview
* @since 3.2.0
*/
protected Ajaxcustomview $ajax;
/**
* 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 Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Libraries|null $libraries The compiler libraries model object.
* @param Templatelayout|null $templateLayout The compiler template layout object.
* @param Dynamicget|null $dynamic The compiler dynamic get data object.
* @param Loader|null $loader The compiler loader object.
* @param Javascriptcustomview|null $javascript The modelling javascript object.
* @param Csscustomview|null $css The modelling css object.
* @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
*/
public function __construct(?Config $config = null, ?EventInterface $event = null,
?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)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->templateLayout = $templateLayout ?: Compiler::_('Templatelayout.Data');
$this->dynamic = $dynamic ?: Compiler::_('Dynamicget.Data');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->javascript = $javascript ?: Compiler::_('Model.Javascriptcustomview');
$this->css = $css ?: Compiler::_('Model.Csscustomview');
$this->php = $php ?: Compiler::_('Model.Phpcustomview');
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxcustomview');
$this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get all Custom View Data
*
* @param int $id The view ID
* @param string $table The view table
*
* @return object|null The view data
* @since 3.2.0
*/
public function get(int $id, string $table = 'site_view'): ?object
{
if (!isset($this->data[$id . $table]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$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)
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$item = $this->db->loadObject();
// fix alias to use in code
$item->code = Unique::code(
StringHelper::safe($item->codename), $this->config->build_target
);
$item->Code = StringHelper::safe($item->code, 'F');
$item->CODE = StringHelper::safe($item->code, 'U');
// Trigger Event: jcb_ce_onBeforeModelCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeModelCustomViewData',
array(&$component_context, &$item, &$id, &$table)
);
// set GUI mapper
$guiMapper = [
'table' => $table,
'id' => (int) $id,
'field' => 'default',
'type' => 'html'
];
// set the default data
$item->default = $this->gui->set(
$this->customcode->update(base64_decode((string) $item->default)),
$guiMapper
);
// load context if not set
if (!isset($item->context)
|| !StringHelper::check(
$item->context
))
{
$item->context = $item->code;
}
else
{
// always make sure context is a safe string
$item->context = StringHelper::safe($item->context);
}
// set the libraries
$this->libraries->set($item->code, $item);
// setup template and layout data
$this->templateLayout->set($item->default, $item->code);
// set uikit version 2
$this->loader->uikit($item->code, $item->default);
// auto loaders
$this->loader->set($item->code, $item->default);
// set the main get data
$main_get = $this->dynamic->get(
array($item->main_get), $item->code, $item->context
);
$item->main_get = ArrayHelper::check($main_get) ? $main_get[0] : null;
// set the custom_get data
$item->custom_get = (isset($item->custom_get)
&& JsonHelper::check($item->custom_get))
? json_decode((string) $item->custom_get, true) : null;
if (ArrayHelper::check($item->custom_get))
{
$item->custom_get = $this->dynamic->get(
$item->custom_get, $item->code, $item->context
);
}
// set php scripts
$this->php->set($item, $table);
// set javascript scripts
$this->javascript->set($item, $table);
// set css scripts
$this->css->set($item);
// set Ajax for this view
$this->ajax->set($item, $table);
// set the custom buttons
$this->custombuttons->set($item, $table);
// Trigger Event: jcb_ce_onAfterModelCustomViewData
$this->event->trigger(
'jcb_ce_onAfterModelCustomViewData',
array(&$component_context, &$item)
);
// set the found data
$this->data[$id . $table] = $item;
}
// return the found data
return $this->data[$id . $table];
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,324 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Dynamicget;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Dynamicget;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Dynamic Get Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'dynamic_get',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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 Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Dynamicget Model
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* 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 Registry|null $registry The compiler registry object.
* @param EventInterface|null $event The compiler event api object.
* @param Customcode|null $customcode The compiler customcode object.
* @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)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->dynamic = $dynamic ?: Compiler::_('Model.Dynamicget');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Dynamic 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 array|null array of object/s on success
* @since 3.2.0
*/
public function get(array $ids, string $view_code, string $context): ?array
{
if ($ids === [])
{
return null;
}
$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.*');
$query->from('#__componentbuilder_dynamic_get AS a');
$query->where('a.id IN (' . $ids . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$results = $this->db->loadObjectList();
foreach ($results as $_nr => &$result)
{
// Trigger Event: jcb_ce_onBeforeModelDynamicGetData
$this->event->trigger(
'jcb_ce_onBeforeModelDynamicGetData',
array(&$component_context, &$result, &$result->id, &$view_code, &$context)
);
// set GUI mapper id
$this->guiMapper['id'] = (int) $result->id;
// add calculations if set
if ($result->addcalculation == 1
&& StringHelper::check(
$result->php_calculation
))
{
// set GUI mapper field
$guiMapper['field'] = 'php_calculation';
$result->php_calculation = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->php_calculation)
),
$this->guiMapper
);
}
// setup the router parse
if (isset($result->add_php_router_parse)
&& $result->add_php_router_parse == 1
&& isset($result->php_router_parse)
&& StringHelper::check(
$result->php_router_parse
))
{
// set GUI mapper field
$this->guiMapper['field'] = 'php_router_parse';
$result->php_router_parse = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->php_router_parse)
),
$this->guiMapper
);
}
else
{
$result->add_php_router_parse = 0;
}
// The array of the php scripts that should be added to the script builder
$phpSripts = [
'php_before_getitem',
'php_after_getitem',
'php_before_getitems',
'php_after_getitems',
'php_getlistquery'
];
// load the php scripts
foreach ($phpSripts as $script)
{
// add php script to the script builder
if (isset($result->{'add_' . $script})
&& $result->{'add_' . $script} == 1
&& isset($result->{$script})
&& StringHelper::check(
$result->{$script}
))
{
// move all main gets out to the custom script builder
if ($result->gettype <= 2)
{
// set GUI mapper field
$this->guiMapper['field'] = $script;
$this->guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$result->{$script},
$this->config->build_target . '_' . $script,
$view_code,
null,
$this->guiMapper,
true,
true,
true
);
unset($this->guiMapper['prefix']);
// remove from local item
unset($result->{$script});
unset($result->{'add_' . $script});
}
else
{
// set GUI mapper field
$this->guiMapper['field'] = $script;
$this->guiMapper['prefix'] = PHP_EOL;
// only for custom gets
$result->{$script} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->{$script})
),
$this->guiMapper
);
unset($this->guiMapper['prefix']);
}
}
else
{
// remove from local item
unset($result->{$script});
unset($result->{'add_' . $script});
}
}
// set the getmethod code name
$result->key = StringHelper::safe(
$view_code . ' ' . $result->name . ' ' . $result->id
);
// set the dynamic get
$this->dynamic->set($result, $view_code, $context);
// load the events if any is set
if ($result->gettype == 1
&& JsonHelper::check(
$result->plugin_events
))
{
$result->plugin_events = json_decode(
(string) $result->plugin_events, true
);
}
else
{
$result->plugin_events = '';
}
// Trigger Event: jcb_ce_onAfterModelDynamicGetData
$this->event->trigger(
'jcb_ce_onAfterModelDynamicGetData',
array(&$component_context, &$result, &$result->id, &$view_code, &$context)
);
}
return $results;
}
return null;
}
}

View File

@ -0,0 +1,281 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Dynamicget;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Dynamic Get Selection Class
*
* @since 3.2.0
*/
class Selection
{
/**
* Admin view table names
*
* @var array
* @since 3.2.0
*/
protected array $name;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* 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 Registry|null $registry The compiler registry object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Data Selection of the dynamic get
*
* @param string $methodKey The method unique key
* @param string $viewCode 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 string $type The target type (db||view)
* @param int|null $rowType The row type
*
* @return array|null the select query
* @since 3.2.0
*/
public function get(string $methodKey, string $viewCode,
string $string, string $asset, string $as, string $type, ?int $rowType = null): ?array
{
if (StringHelper::check($string))
{
if ('db' === $type)
{
$table = '#__' . $asset;
$queryName = $asset;
$view = '';
}
elseif ('view' === $type)
{
$view = $this->name($asset);
$table = '#__' . $this->config->component_code_name . '_' . $view;
$queryName = $view;
}
else
{
return null;
}
// just get all values from table if * is found
if ($string === '*' || strpos($string, '*') !== false)
{
if ($type == 'view')
{
// TODO move getViewTableColumns to its own class
$_string = Helper::_('getViewTableColumns',
[$asset, $as, $rowType]
);
}
else
{
// TODO move getDbTableColumns to its own class
$_string = Helper::_('getDbTableColumns',
[$asset, $as, $rowType]
);
}
// get only selected values
$lines = explode(PHP_EOL, (string) $_string);
// make sure to set the string to *
$string = '*';
}
else
{
// get only selected values
$lines = explode(PHP_EOL, $string);
}
// only continue if lines are available
if (ArrayHelper::check($lines))
{
$gets = [];
$keys = [];
// first load all options
foreach ($lines as $line)
{
if (strpos($line, 'AS') !== false)
{
$lineArray = explode("AS", $line);
}
elseif (strpos($line, 'as') !== false)
{
$lineArray = explode("as", $line);
}
else
{
$lineArray = array($line, null);
}
// set the get and key
$get = trim($lineArray[0]);
$key = trim($lineArray[1]);
// only add the view (we must adapt this)
if ($this->registry->exists('builder.get_as_lookup.' . $methodKey . '.' . $get)
&& 'a' != $as
&& is_numeric($rowType) && 1 == $rowType
&& 'view' === $type
&& strpos('#' . $key, '#' . $view . '_') === false)
{
// this is a problem (TODO) since we may want to not add the view name.
$key = $view . '_' . trim($key);
}
// continue only if we have get
if (StringHelper::check($get))
{
$gets[] = $this->db->quote($get);
if (StringHelper::check($key))
{
$this->registry->
set('builder.get_as_lookup.' . $methodKey . '.' . $get, $key);
}
else
{
$key = str_replace(
$as . '.', '', $get
);
$this->registry->
set('builder.get_as_lookup.' . $methodKey . '.' . $get, $key);
}
// set the keys
$keys[] = $this->db->quote(
$key
);
// make sure we have the view name
if (StringHelper::check($view))
{
// prep the field name
$field = str_replace($as . '.', '', $get);
// load to the site fields memory bucket
$this->registry->
set('builder.site_fields.' . $view . '.' . $field . '.' . $methodKey . '___' . $as,
['site' => $viewCode, 'get' => $get, 'as' => $as, 'key' => $key]);
}
}
}
if (ArrayHelper::check($gets)
&& ArrayHelper::check($keys))
{
// single joined selection needs the prefix to the values to avoid conflict in the names
// so we must still add then AS
if ($string == '*' && (is_null($rowType) || 1 != $rowType))
{
$querySelect = "\$query->select('" . $as . ".*');";
}
else
{
$querySelect = '$query->select($db->quoteName('
. PHP_EOL . Indent::_(3) . 'array(' . implode(
',', $gets
) . '),' . PHP_EOL . Indent::_(3) . 'array('
. implode(',', $keys) . ')));';
}
$queryFrom = '$db->quoteName(' . $this->db->quote($table)
. ', ' . $this->db->quote($as) . ')';
// return the select query
return [
'select' => $querySelect,
'from' => $queryFrom,
'name' => $queryName,
'table' => $table,
'type' => $type,
'select_gets' => $gets,
'select_keys' => $keys
];
}
}
}
return null;
}
/**
* Get the Admin view table name
*
* @param int $id The item id to add
*
* @return string the admin view code name
* @since 3.2.0
*/
protected function name(int $id): string
{
// get name if not set
if (!isset($this->name[$id]))
{
$this->name[$id] = StringHelper::safe(
GetHelper::var('admin_view', $id, 'id', 'name_single')
);
}
return $this->name[$id] ?? 'error';
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -144,7 +144,7 @@ class InstallScript implements GetScriptInterface
else
{
// get the flight key
$flight = str_replace('php_', '', $method);
$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

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -13,6 +13,11 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\Service\Crypt;
use VDM\Joomla\Componentbuilder\Service\Server;
use VDM\Joomla\Componentbuilder\Compiler\Service\Database;
use VDM\Joomla\Componentbuilder\Compiler\Service\Model;
use VDM\Joomla\Componentbuilder\Compiler\Service\Mapper;
use VDM\Joomla\Componentbuilder\Compiler\Service\Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Service\Event;
use VDM\Joomla\Componentbuilder\Compiler\Service\History;
@ -21,8 +26,16 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Service\Power;
use VDM\Joomla\Componentbuilder\Compiler\Service\Component;
use VDM\Joomla\Componentbuilder\Compiler\Service\Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Library;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Service\Extension;
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\Interfaces\FactoryInterface;
/**
@ -30,7 +43,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Field;
*
* @since 3.2.0
*/
abstract class Factory
abstract class Factory implements FactoryInterface
{
/**
* Global Compiler Container
@ -80,7 +93,7 @@ abstract class Factory
}
/**
* Get a the global compiler container
* Get the global compiler container
*
* @return Container
* @since 3.2.0
@ -103,7 +116,12 @@ abstract class Factory
*/
protected static function createContainer(): Container
{
$container = (new Container())
return (new Container())
->registerServiceProvider(new Crypt())
->registerServiceProvider(new Server())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Mapper())
->registerServiceProvider(new Compiler())
->registerServiceProvider(new Event())
->registerServiceProvider(new History())
@ -112,10 +130,15 @@ abstract class Factory
->registerServiceProvider(new Customcode())
->registerServiceProvider(new Power())
->registerServiceProvider(new Component())
->registerServiceProvider(new Adminview())
->registerServiceProvider(new Library())
->registerServiceProvider(new Customview())
->registerServiceProvider(new Templatelayout())
->registerServiceProvider(new Extension())
->registerServiceProvider(new Field());
return $container;
->registerServiceProvider(new Field())
->registerServiceProvider(new Joomlamodule())
->registerServiceProvider(new Joomlaplugin())
->registerServiceProvider(new Utilities());
}
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -102,8 +102,8 @@ class Customcode
= true;
}
if (strpos($field->javascript_view_footer, "token") !== false
|| strpos($field->javascript_view_footer, "task=ajax") !== false)
if (strpos((string) $field->javascript_view_footer, "token") !== false
|| strpos((string) $field->javascript_view_footer, "task=ajax") !== false)
{
if (!isset($this->dispenser->hub['token']))
{
@ -182,8 +182,8 @@ class Customcode
{
$field->javascript_views_footer_decoded = true;
}
if (strpos($field->javascript_views_footer, "token") !== false
|| strpos($field->javascript_views_footer, "task=ajax") !== false)
if (strpos((string) $field->javascript_views_footer, "token") !== false
|| strpos((string) $field->javascript_views_footer, "task=ajax") !== false)
{
if (!isset($this->dispenser->hub['token']))
{

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -196,7 +196,7 @@ class Data
$field->type = $field->fieldtype;
// load the values form params
$field->xml = $this->customcode->update(json_decode($field->xml));
$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);
@ -204,7 +204,7 @@ class Data
// load the type values form type params
$field->properties = (isset($field->properties)
&& JsonHelper::check($field->properties))
? json_decode($field->properties, true) : null;
? json_decode((string) $field->properties, true) : null;
if (ArrayHelper::check($field->properties))
{
$field->properties = array_values($field->properties);
@ -243,16 +243,16 @@ class Data
))
{
$field->initiator_save_key = md5(
$field->initiator_on_save_model
(string) $field->initiator_on_save_model
);
$field->initiator_save = explode(
PHP_EOL, $this->placeholder->update(
$this->customcode->update(
base64_decode(
$field->initiator_on_save_model
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $field->initiator_on_save_model
)
)
), $this->placeholder->active
)
)
);
}
if (StringHelper::check(
@ -260,32 +260,32 @@ class Data
))
{
$field->initiator_get_key = md5(
$field->initiator_on_get_model
(string) $field->initiator_on_get_model
);
$field->initiator_get = explode(
PHP_EOL, $this->placeholder->update(
$this->customcode->update(
base64_decode(
$field->initiator_on_get_model
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $field->initiator_on_get_model
)
)
), $this->placeholder->active
)
)
);
}
// set the field modeling
// set the field modelling
$field->model_field['save'] = explode(
PHP_EOL, $this->placeholder->update(
$this->customcode->update(
base64_decode($field->on_save_model_field)
), $this->placeholder->active
)
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $field->on_save_model_field)
)
)
);
$field->model_field['get'] = explode(
PHP_EOL, $this->placeholder->update(
$this->customcode->update(
base64_decode($field->on_get_model_field)
), $this->placeholder->active
)
PHP_EOL, $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $field->on_get_model_field)
)
)
);
// remove the original values
unset(

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -88,9 +88,10 @@ class CoreValidation implements CoreValidationInterface
}
// remove the Rule.php from the name
$this->rules = array_map( function ($name) {
return str_replace(array('./','Rule.php'), '', $name);
}, $rules);
$this->rules = array_map(
fn($name): string => str_replace(array('./','Rule.php'), '', (string) $name),
$rules
);
}
// return rules if found
@ -99,9 +100,10 @@ class CoreValidation implements CoreValidationInterface
// check if the names should be all lowercase
if ($lowercase)
{
return array_map( function($item) {
return strtolower($item);
}, $this->rules);
return array_map(
fn($item): string => strtolower((string) $item),
$this->rules
);
}
return $this->rules;
}

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -133,8 +133,8 @@ class Name
|| strpos($requeSt_id, '_request_catid') !== false)
{
// keep it then, don't change
$name = $this->placeholder->update(
$requeSt_id, $this->placeholder->active
$name = $this->placeholder->update_(
$requeSt_id
);
}
else
@ -146,20 +146,20 @@ class Name
if (StringHelper::check($listViewName))
{
// check if we should use another Text Name as this views name
$otherName = $this->placeholder->update(
$otherName = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'othername="', '"'
), $this->placeholder->active
)
);
$otherViews = $this->placeholder->update(
$otherViews = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'views="', '"'
), $this->placeholder->active
)
);
$otherView = $this->placeholder->update(
$otherView = $this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'view="', '"'
), $this->placeholder->active
)
);
// This is to link other view category
if (StringHelper::check($otherName)
@ -198,10 +198,10 @@ class Name
{
// get value from xml
$xml = FieldHelper::safe(
$this->placeholder->update(
$this->placeholder->update_(
GetHelper::between(
$field['settings']->xml, 'name="', '"'
), $this->placeholder->active
)
)
);
// check if a value was found

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -53,7 +53,7 @@ class TypeName
))
{
// search for own custom fields
if (strpos($field['settings']->type_name, '@') !== false)
if (strpos((string) $field['settings']->type_name, '@') !== false)
{
// set own custom field
$field['settings']->own_custom = $field['settings']->type_name;
@ -66,8 +66,8 @@ class TypeName
);
// if custom (we must use the xml value)
if (strtolower($type_name) === 'custom'
|| strtolower($type_name) === 'customuser')
if (strtolower((string) $type_name) === 'custom'
|| strtolower((string) $type_name) === 'customuser')
{
$type = TypeHelper::safe(
GetHelper::between(

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -130,12 +130,12 @@ class Validation
// open and set the validation rule
$this->registry->set("validation.rules.${validation_rule}",
$this->gui->set(
$this->placeholder->update(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
$php_code
(string) $php_code
)
), $this->placeholder->active
)
),
array(
'table' => 'validation_rule',

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -38,7 +38,7 @@ interface DispenserInterface
* @since 3.2.0
*/
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool;
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add = false): bool;
/**
* Get the script from the customcode dispenser

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -19,6 +19,164 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
*/
interface PlaceholderInterface
{
/**
* Set content
*
* @param string $key The main string key
* @param mixed $value The values to set
* @param bool $hash Add the hash around the key
*
* @return void
* @since 3.2.0
*/
public function set(string $key, $value, bool $hash = true);
/**
* Get content by key
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get(string $key);
/**
* Does key exist at all in any variation
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist(string $key): bool;
/**
* Add content
*
* @param string $key The main string key
* @param mixed $value The values to set
* @param bool $hash Add the hash around the key
*
* @return void
* @since 3.2.0
*/
public function add(string $key, $value, bool $hash = true);
/**
* Remove content
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove(string $key);
/**
* Set content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_(string $key, $value);
/**
* Get content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get_(string $key);
/**
* Does key exist with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist_(string $key): bool;
/**
* Add content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_(string $key, $value);
/**
* Remove content with [ [ [ ... ] ] ] hash
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove_(string $key);
/**
* Set content with # # # hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function set_h(string $key, $value);
/**
* Get content with # # # hash
*
* @param string $key The main string key
*
* @return mixed
* @since 3.2.0
*/
public function get_h(string $key);
/**
* Does key exist with # # # hash
*
* @param string $key The main string key
*
* @return bool
* @since 3.2.0
*/
public function exist_h(string $key): bool;
/**
* Add content with # # # hash
*
* @param string $key The main string key
* @param mixed $value The values to set
*
* @return void
* @since 3.2.0
*/
public function add_h(string $key, $value);
/**
* Remove content with # # # hash
*
* @param string $key The main string key
*
* @return void
* @since 3.2.0
*/
public function remove_h(string $key);
/**
* Set a type of placeholder with set of values
*
@ -57,6 +215,16 @@ interface PlaceholderInterface
*/
public function update(string $data, array &$placeholder, int $action = 1): string;
/**
* Update the data with the active placeholders
*
* @param string $data The actual data
*
* @return string
* @since 3.2.0
*/
public function update_(string $data): string;
/**
* return the placeholders for inserted and replaced code
*

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -166,11 +166,11 @@ class History implements HistoryInterface
// check the note
if (JsonHelper::check($object->version_note))
{
$version_note = json_decode($object->version_note, true);
$version_note = json_decode((string) $object->version_note, true);
}
else
{
$version_note = array('component' => array());
$version_note = array('component' => []);
}
// set watch
switch ($action)
@ -183,7 +183,7 @@ class History implements HistoryInterface
)) !== false)
{
// last version that was used to build/compile
$this->tmp = json_decode($object->version_data);
$this->tmp = json_decode((string) $object->version_data);
// remove it from this component
unset($version_note['component'][$key]);
}

View File

@ -0,0 +1,883 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Joomlamodule;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as Module;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
/**
* Joomla Module Builder Class
*
* @since 3.2.0
*/
class Builder
{
/**
* Compiler Joomla Module Data Class
*
* @var Module
* @since 3.2.0
*/
protected Module $module;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Counter
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Compiler Utilities Folder
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* Compiler Utilities File
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* Compiler Utilities Files
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* Constructor
*
* @param Module|null $module The compiler Joomla module data object.
* @param Component|null $component The component class.
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param EventInterface|null $event The compiler event api object.
* @param Counter|null $counter The compiler counter object.
* @param Folder|null $folder The compiler folder object.
* @param File|null $file The compiler file object.
* @param Files|null $files The compiler files object.
*
* @since 3.2.0
*/
public function __construct(?Module $module = null, ?Component $component = null,
?Config $config = null, ?Registry $registry = null,
?Dispenser $dispenser = null, ?EventInterface $event = null,
?Counter $counter = null, ?Folder $folder = null,
?File $file = null, ?Files $files = null)
{
$this->module = $module ?: Compiler::_('Joomlamodule.Data');
$this->component = $component ?: Compiler::_('Component');
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->event = $event ?: Compiler::_('Event');
$this->counter = $counter ?? Compiler::_('Utilities.Counter');
$this->folder = $folder ?? Compiler::_('Utilities.Folder');
$this->file = $file ?? Compiler::_('Utilities.File');
$this->files = $files ?? Compiler::_('Utilities.Files');
}
/**
* Build the Modules files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function run()
{
if ($this->module->exists())
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$modules = $this->module->get();
// Trigger Event: jcb_ce_onBeforeSetModules
$this->event->trigger(
'jcb_ce_onBeforeBuildModules',
array(&$component_context, &$modules)
);
foreach ($modules as $module)
{
if (ObjectHelper::check($module)
&& isset($module->folder_name)
&& StringHelper::check(
$module->folder_name
))
{
// module path
$module->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $module->folder_name;
// set the module paths
$this->registry->set('dynamic_paths.' . $module->key, $module->folder_path);
// make sure there is no old build
$this->folder->remove($module->folder_path);
// creat the main module folder
$this->folder->create($module->folder_path);
// set main mod file
$fileDetails = array('path' => $module->folder_path . '/'
. $module->file_name . '.php',
'name' => $module->file_name . '.php',
'zip' => $module->file_name . '.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// main modfile' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MODCODE')
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
// set custom_get
if ($module->custom_get)
{
$fileDetails = array(
'path' => $module->folder_path . '/data.php',
'name' => 'data.php',
'zip' => 'data.php'
);
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// get data file' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL . PHP_EOL .
'/**' . PHP_EOL .
' * Module ' . $module->official_name . ' Data'
. PHP_EOL .
' */' . PHP_EOL .
"class " . $module->class_data_name
. ' extends \JObject' . PHP_EOL .
"{" . Placefix::_h('DYNAMICGETS') . "}"
. PHP_EOL
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
}
// set helper file
if ($module->add_class_helper >= 1)
{
$fileDetails = array('path' => $module->folder_path
. '/helper.php',
'name' => 'helper.php',
'zip' => 'helper.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// helper file' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('HELPERCODE')
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
}
// set main xml file
$fileDetails = array('path' => $module->folder_path . '/'
. $module->file_name . '.xml',
'name' => $module->file_name . '.xml',
'zip' => $module->file_name . '.xml');
$this->file->write(
$fileDetails['path'],
$this->getXML($module)
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
// set tmpl folder
$this->folder->create($module->folder_path . '/tmpl');
// set default file
$fileDetails = array('path' => $module->folder_path
. '/tmpl/default.php',
'name' => 'default.php',
'zip' => 'tmpl/default.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// default tmpl' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MODDEFAULT')
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
// set install script if needed
if ($module->add_install_script)
{
$fileDetails = array('path' => $module->folder_path
. '/script.php',
'name' => 'script.php',
'zip' => 'script.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
}
// set readme if found
if ($module->addreadme)
{
$fileDetails = array('path' => $module->folder_path
. '/README.md',
'name' => 'README.md',
'zip' => 'README.md');
$this->file->write($fileDetails['path'], $module->readme);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
}
// set the folders target path
$target_path = '';
if ($module->target_client === 'administrator')
{
$target_path = '/administrator';
}
// check if we have custom fields needed for scripts
$module->add_scripts_field = false;
$field_script_bucket = [];
// add any css from the fields
if (($css = $this->dispenser->get(
'css_view', $module->key
)) !== null
&& StringHelper::check($css))
{
// make sure this script does not have PHP
if (strpos((string) $css, '<?php') === false)
{
// make sure the field is added
$module->add_scripts_field = true;
// create the css folder
$this->folder->create($module->folder_path . '/css');
// add the CSS file
$fileDetails = array('path' => $module->folder_path
. '/css/mod_admin.css',
'name' => 'mod_admin.css',
'zip' => 'mod_admin.css');
$this->file->write(
$fileDetails['path'],
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . $css
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
// add the field script
$field_script_bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom CSS";
$field_script_bucket[] = Indent::_(2)
. "\$document->addStyleSheet('" . $target_path
. "/modules/" . $module->folder_name
. "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
}
}
// add any JavaScript from the fields
if (($javascript = $this->dispenser->get(
'view_footer', $module->key
)) !== null
&& StringHelper::check($javascript))
{
// make sure this script does not have PHP
if (strpos((string) $javascript, '<?php') === false)
{
// make sure the field is added
$module->add_scripts_field = true;
// add the JavaScript file
$this->folder->create($module->folder_path . '/js');
// add the CSS file
$fileDetails = array('path' => $module->folder_path
. '/js/mod_admin.js',
'name' => 'mod_admin.js',
'zip' => 'mod_admin.js');
$this->file->write(
$fileDetails['path'],
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . $javascript
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
// add the field script
$field_script_bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom JS";
$field_script_bucket[] = Indent::_(2)
. "\$document->addScript('" . $target_path
. "/modules/" . $module->folder_name
. "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
}
}
// set fields folders if needed
if ($module->add_scripts_field
|| (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2))
{
// create fields folder
$this->folder->create($module->folder_path . '/fields');
// add the custom script field
if ($module->add_scripts_field)
{
$fileDetails = [
'path' => $module->folder_path
. '/fields/modadminvvvvvvvdm.php',
'name' => 'modadminvvvvvvvdm.php',
'zip' => 'modadminvvvvvvvdm.php'
];
$this->file->write(
$fileDetails['path'],
$this->getCustomScriptField(
$field_script_bucket
)
);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
}
}
// set rules folders if needed
if (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2)
{
// create rules folder
$this->folder->create($module->folder_path . '/rules');
}
// set forms folder if needed
if (isset($module->form_files)
&& ArrayHelper::check(
$module->form_files
))
{
// create forms folder
$this->folder->create($module->folder_path . '/forms');
// set the template files
foreach ($module->form_files as $file => $fields)
{
// set file details
$fileDetails = array('path' => $module->folder_path
. '/forms/' . $file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file
. '.xml');
// build basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' . $this->config->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
foreach ($fields as $field_name => $fieldsets)
{
if (!$add_component_path)
{
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset(
$module->fieldsets_paths[$file
. $field_name . $fieldset]
)
&& $module->fieldsets_paths[$file
. $field_name . $fieldset] == 1)
{
$add_component_path = true;
}
}
}
}
// only add if part of the component field types path is required
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
$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"';
$xml .= PHP_EOL . '>';
}
else
{
$xml .= PHP_EOL . '<form>';
}
// add the fields
foreach ($fields as $field_name => $fieldsets)
{
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string) $field_name, '.') !== false)
{
$field_names = explode('.', (string) $field_name);
if (count((array) $field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
{
// default to the field set name
$label = $fieldset;
if (isset($module->fieldsets_label[$file . $field_name . $fieldset]))
{
$label = $module->fieldsets_label[$file . $field_name . $fieldset];
}
// add path to module rules and custom fields
if (isset($module->fieldsets_paths[$file . $field_name . $fieldset])
&& ($module->fieldsets_paths[$file . $field_name . $fieldset] == 2
|| $module->fieldsets_paths[$file . $field_name . $fieldset] == 3))
{
if ($module->target == 2)
{
if (!isset($module->add_rule_path[$file . $field_name . $fieldset]))
{
$module->add_rule_path[$file . $field_name . $fieldset] =
'/administrator/modules/'
. $module->file_name . '/rules';
}
if (!isset($module->add_field_path[$file . $field_name . $fieldset]))
{
$module->add_field_path[$file . $field_name . $fieldset] =
'/administrator/modules/'
. $module->file_name . '/fields';
}
}
else
{
if (!isset($module->add_rule_path[$file . $field_name . $fieldset]))
{
$module->add_rule_path[$file . $field_name . $fieldset] =
'/modules/' . $module->file_name
. '/rules';
}
if (!isset($module->add_field_path[$file . $field_name . $fieldset]))
{
$module->add_field_path[$file . $field_name . $fieldset] =
'/modules/' . $module->file_name
. '/fields';
}
}
}
// add path to module rules and custom fields
if (isset($module->add_rule_path[$file . $field_name . $fieldset])
|| isset($module->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
if (isset($module->add_rule_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $module->add_rule_path[$file . $field_name . $fieldset] . '"';
}
if (isset($module->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' . $module->add_field_path[$file . $field_name . $fieldset] . '"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '">';
}
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset );
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($fileDetails['path'], $xml);
$this->files->appendArray($module->key, $fileDetails);
// count the file created
$this->counter->file++;
}
}
// set SQL stuff if needed
if ($module->add_sql || $module->add_sql_uninstall)
{
// create SQL folder
$this->folder->create($module->folder_path . '/sql');
// create mysql folder
$this->folder->create(
$module->folder_path . '/sql/mysql'
);
// now set the install file
if ($module->add_sql)
{
$this->file->write(
$module->folder_path . '/sql/mysql/install.sql',
$module->sql
);
// count the file created
$this->counter->file++;
}
// now set the uninstall file
if ($module->add_sql_uninstall)
{
$this->file->write(
$module->folder_path
. '/sql/mysql/uninstall.sql',
$module->sql_uninstall
);
// count the file created
$this->counter->file++;
}
}
// creat the language folder
$this->folder->create($module->folder_path . '/language');
// also create the lang tag folder
$this->folder->create(
$module->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
// check if this lib has files
if (isset($module->files)
&& ArrayHelper::check($module->files))
{
// add to component files
foreach ($module->files as $file)
{
// set the pathfinder
$file['target_type'] = $module->target_type;
$file['target_id'] = $module->id;
$this->component->appendArray('files', $file);
}
}
// check if this lib has folders
if (isset($module->folders)
&& ArrayHelper::check($module->folders))
{
// add to component folders
foreach ($module->folders as $folder)
{
// set the pathfinder
$folder['target_type'] = $module->target_type;
$folder['target_id'] = $module->id;
$this->component->appendArray('folders', $folder);
}
}
// check if this module has urls
if (isset($module->urls)
&& ArrayHelper::check($module->urls))
{
// add to component urls
foreach ($module->urls as $n => &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type'] > 1
&& isset($url['url'])
&& StringHelper::check(
$url['url']
))
{
// set file name
$fileName = basename((string) $url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media path if not set
$this->folder->create(
$module->folder_path . $path
);
// set the path to module file
$url['path'] = $module->folder_path . $path
. '/' . $fileName; // we need this for later
// write data to path
$this->file->write($url['path'], $data);
// count the file created
$this->counter->file++;
}
}
}
}
}
}
}
/**
* get the module xml template
*
* @param object $module The module object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object &$module): string
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="module" version="'
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" client="'
. $module->target_client . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $module->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $module->module_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $module->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
/**
* get the module admin custom script field
*
* @param array $fieldScriptBucket The field
*
* @return string
* @since 3.2.0
*
*/
protected function getCustomScriptField(array $fieldScriptBucket): string
{
$form_field_class = [];
$form_field_class[] = Placefix::_h('BOM') . PHP_EOL;
$form_field_class[] = "//" . Line::_(__Line__, __Class__)
. " No direct access to this file";
$form_field_class[] = "defined('_JEXEC') or die('Restricted access');";
$form_field_class[] = PHP_EOL . "use Joomla\CMS\Form\FormField;";
$form_field_class[] = "use Joomla\CMS\Factory;";
$form_field_class[] = PHP_EOL
. "class JFormFieldModadminvvvvvvvdm extends FormField";
$form_field_class[] = "{";
$form_field_class[] = Indent::_(1)
. "protected \$type = 'modadminvvvvvvvdm';";
$form_field_class[] = PHP_EOL . Indent::_(1)
. "protected function getLabel()";
$form_field_class[] = Indent::_(1) . "{";
$form_field_class[] = Indent::_(2) . "return;";
$form_field_class[] = Indent::_(1) . "}";
$form_field_class[] = PHP_EOL . Indent::_(1)
. "protected function getInput()";
$form_field_class[] = Indent::_(1) . "{";
$form_field_class[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Get the document";
$form_field_class[] = Indent::_(2)
. "\$document = Factory::getDocument();";
$form_field_class[] = implode(PHP_EOL, $fieldScriptBucket);
$form_field_class[] = Indent::_(2) . "return; // noting for now :)";
$form_field_class[] = Indent::_(1) . "}";
$form_field_class[] = "}";
return implode(PHP_EOL, $form_field_class);
}
}

View File

@ -0,0 +1,960 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Joomlamodule;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Joomla Module Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Joomla Plugins Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Compiler Dynamic Get Data
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* 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 Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler Language object.
* @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 Libraries|null $libraries The compiler libraries model object.
* @param Dynamicget|null $dynamic The compiler dynamic get data 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, ?Libraries $libraries = null,
?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->dynamic = $dynamic ?: Compiler::_('Dynamicget.Data');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get the Joomla Module/s
*
* @param int|null $id the module id
*
* @return object|array|null if ID found it returns object, if no ID given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Module/s exists
*
* @param int|null $id the module id
*
* @return bool if ID found it returns true, if no ID given it returns true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Module
*
* @param int $id the module id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_module AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_module_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('u.joomla_module') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_module_files_folders_urls', 'f'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('f.joomla_module') . ')'
);
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
$query->where($this->db->quoteName('a.published') . ' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the module data
$module = $this->db->loadObject();
// tweak system to set stuff to the module domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$module->target_type = 'M0dU|3';
$module->key = $module->id . '_' . $module->target_type;
// update to point to module
$this->config->build_target = $module->key;
$this->config->lang_target = $module->key;
// set version if not set
if (empty($module->module_version))
{
$module->module_version = '1.0.0';
}
// set target client
if ($module->target == 2)
{
$module->target_client = 'administrator';
}
else
{
// default is site area
$module->target_client = 'site';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_module',
'id' => (int) $id, 'type' => 'php');
// update the name if it has dynamic values
$module->name = $this->placeholder->update_(
$this->customcode->update($module->name)
);
// set safe class function name
$module->code_name
= ClassfunctionHelper::safe(
$module->name
);
// alias of code name
$module->class_name = $module->code_name;
// set official name
$module->official_name = StringHelper::safe(
$module->name, 'W'
);
$this->config->set('lang_prefix', 'MOD_' . strtoupper((string) $module->code_name));
// set lang prefix
$module->lang_prefix = $this->config->lang_prefix;
// set module class name
$module->class_helper_name = 'Mod' . ucfirst((string) $module->code_name)
. 'Helper';
$module->class_data_name = 'Mod' . ucfirst((string) $module->code_name)
. 'Data';
// set module install class name
$module->installer_class_name = 'mod_' . ucfirst(
(string) $module->code_name
) . 'InstallerScript';
// set module folder name
$module->folder_name = 'mod_' . strtolower((string) $module->code_name);
// set the zip name
$module->zip_name = $module->folder_name . '_v' . str_replace(
'.', '_', (string) $module->module_version
) . '__J' . $this->config->joomla_version;
// set module file name
$module->file_name = $module->folder_name;
// set module context
$module->context = $module->file_name . '.' . $module->id;
// set official_name lang strings
$this->language->set(
$module->key, $this->config->lang_prefix, $module->official_name
);
// set some placeholder for this module
$this->placeholder->set('Module_name', $module->official_name);
$this->placeholder->set('Module', ucfirst(
(string) $module->code_name
));
$this->placeholder->set('module', strtolower(
(string) $module->code_name
));
$this->placeholder->set('module.version', $module->module_version);
$this->placeholder->set('module_version', str_replace(
'.', '_', (string) $module->module_version
));
// set description (TODO) add description field to module
if (!isset($module->description)
|| !StringHelper::check(
$module->description
))
{
$module->description = '';
}
else
{
$module->description = $this->placeholder->update_(
$this->customcode->update($module->description)
);
$this->language->set(
$module->key, $module->lang_prefix . '_DESCRIPTION',
$module->description
);
$module->description = '<p>' . $module->description
. '</p>';
}
// get author name
$project_author = $this->config->project_author;
// set the description
$module->xml_description = "<h1>" . $module->official_name
. " (v." . $module->module_version
. ")</h1> <div style='clear: both;'></div>"
. $module->description . "<p>Created by <a href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started "
. Factory::getDate($module->created)->format("jS F, Y")
. "</small></p>";
// set xml description
$this->language->set(
$module->key, $module->lang_prefix . '_XML_DESCRIPTION',
$module->xml_description
);
// update the readme if set
if ($module->addreadme == 1 && !empty($module->readme))
{
$module->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $module->readme))
);
}
else
{
$module->addreadme = 0;
unset($module->readme);
}
// get the custom_get
$module->custom_get = (isset($module->custom_get)
&& JsonHelper::check($module->custom_get))
? json_decode((string) $module->custom_get, true) : null;
if (ArrayHelper::check($module->custom_get))
{
$module->custom_get = $this->dynamic->get(
$module->custom_get, $module->key, $module->key
);
}
else
{
$module->custom_get = null;
}
// set helper class details
if ($module->add_class_helper >= 1
&& StringHelper::check(
$module->class_helper_code
))
{
if ($module->add_class_helper_header == 1
&& StringHelper::check(
$module->class_helper_header
))
{
// set GUI mapper field
$guiMapper['field'] = 'class_helper_header';
// base64 Decode code
$module->class_helper_header = PHP_EOL
. $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $module->class_helper_header
)
)
),
$guiMapper
) . PHP_EOL;
}
else
{
$module->add_class_helper_header = 0;
$module->class_helper_header = '';
}
// set GUI mapper field
$guiMapper['field'] = 'class_helper_code';
// base64 Decode code
$module->class_helper_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->class_helper_code)
)
),
$guiMapper
);
// set class type
if ($module->add_class_helper == 2)
{
$module->class_helper_type = 'abstract class ';
}
else
{
$module->class_helper_type = 'class ';
}
}
else
{
$module->add_class_helper = 0;
$module->class_helper_code = '';
$module->class_helper_header = '';
}
// base64 Decode mod_code
if (isset($module->mod_code)
&& StringHelper::check($module->mod_code))
{
// set GUI mapper field
$guiMapper['field'] = 'mod_code';
$module->mod_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->mod_code)
)
),
$guiMapper
);
}
else
{
$module->mod_code = "// get the module class sfx";
$module->mod_code .= PHP_EOL
. "\$moduleclass_sfx = htmlspecialchars(\$params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');";
$module->mod_code .= PHP_EOL . "// load the default Tmpl";
$module->mod_code .= PHP_EOL
. "require JModuleHelper::getLayoutPath('mod_"
. strtolower((string) $module->code_name)
. "', \$params->get('layout', 'default'));";
}
// base64 Decode default header
if (isset($module->default_header)
&& StringHelper::check(
$module->default_header
))
{
// set GUI mapper field
$guiMapper['field'] = 'default_header';
$module->default_header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->default_header)
)
),
$guiMapper
);
}
else
{
$module->default_header = '';
}
// base64 Decode default
if (isset($module->default)
&& StringHelper::check($module->default))
{
// set GUI mapper field
$guiMapper['field'] = 'default';
$guiMapper['type'] = 'html';
$module->default = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->default)
)
),
$guiMapper
);
}
else
{
$module->default = '<h1>No Tmpl set</h1>';
}
// start the config array
$module->config_fields = [];
// create the form arrays
$module->form_files = [];
$module->fieldsets_label = [];
$module->fieldsets_paths = [];
$module->add_rule_path = [];
$module->add_field_path = [];
// set global fields rule to default component path
$module->fields_rules_paths = 1;
// set the fields data
$module->fields = (isset($module->fields)
&& JsonHelper::check($module->fields))
? json_decode((string) $module->fields, true) : null;
if (ArrayHelper::check($module->fields))
{
// ket global key
$key = $module->key;
$dynamic_fields = array('fieldset' => 'basic',
'fields_name' => 'params',
'file' => 'config');
foreach ($module->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['module']) || $form['module'] != 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switches
if ($module->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$module->fields_rules_paths = 2;
}
// set where to path is pointing
$module->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$module->add_rule_path[$unique] = $add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$module->add_field_path[$unique] = $add_field_path['path'];
}
}
}
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$module->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['module']) || $form['module'] != 1)
{
// load the form file
if (!isset($module->form_files[$form['file']]))
{
$module->form_files[$form['file']]
= [];
}
if (!isset($module->form_files[$form['file']][$form['fields_name']]))
{
$module->form_files[$form['file']][$form['fields_name']]
= [];
}
if (!isset($module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $module->key, $unique
);
// add the fields to the global form file builder
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($module->fields[$n]);
}
else
{
// load the config form
if (!isset($module->config_fields[$form['fields_name']]))
{
$module->config_fields[$form['fields_name']]
= [];
}
if (!isset($module->config_fields[$form['fields_name']][$form['fieldset']]))
{
$module->config_fields[$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $module->key, $unique
);
// add the fields to the config builder
$module->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($module->fields[$n]);
}
}
else
{
unset($module->fields[$n]);
}
}
}
unset($module->fields);
// set files and folders
$this->filesFolders->set($module);
// set libraries
$this->libraries->set($module->code_name, $module);
// add PHP in module install
$module->add_install_script = false;
$addScriptMethods = array('php_preflight',
'php_postflight',
'php_method');
$addScriptTypes = array('install', 'update',
'uninstall');
// the next are php placeholders
$guiMapper['type'] = 'php';
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset(
$module->{'add_' . $scriptMethod . '_'
. $scriptType}
)
&& $module->{'add_' . $scriptMethod . '_'
. $scriptType} == 1
&& StringHelper::check(
$module->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_'
. $scriptType;
$module->{$scriptMethod . '_' . $scriptType} = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $module->{$scriptMethod . '_'
. $scriptType}
)
)
),
$guiMapper
);
$module->add_install_script = true;
}
else
{
unset($module->{$scriptMethod . '_' . $scriptType});
$module->{'add_' . $scriptMethod . '_'
. $scriptType}
= 0;
}
}
}
// add_sql
if ($module->add_sql == 1
&& StringHelper::check($module->sql))
{
$module->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $module->sql))
);
}
else
{
unset($module->sql);
$module->add_sql = 0;
}
// add_sql_uninstall
if ($module->add_sql_uninstall == 1
&& StringHelper::check(
$module->sql_uninstall
))
{
$module->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->sql_uninstall)
)
);
}
else
{
unset($module->sql_uninstall);
$module->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($module->add_update_server == 1
&& StringHelper::check(
$module->update_server_url
))
{
$module->update_server_url = $this->placeholder->update_(
$this->customcode->update($module->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array('update_server', 'sales_server');
foreach ($serverArray as $server)
{
if ($module->{'add_' . $server} == 1
&& is_numeric(
$module->{$server}
)
&& $module->{$server} > 0)
{
// get the server protocol
$module->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $module->{$server}, 'id', 'protocol'
);
}
else
{
$module->{$server} = 0;
// only change this for sales server (update server can be added loacaly to the zip file)
if ('sales_server' === $server)
{
$module->{'add_' . $server} = 0;
}
$module->{$server . '_protocol'} = 0;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->lang_prefix = $_backup_langPrefix;
$this->placeholder->remove('Module_name');
$this->placeholder->remove('Module');
$this->placeholder->remove('module');
$this->placeholder->remove('module.version');
$this->placeholder->remove('module_version');
$this->data[$id] = $module;
return true;
}
}
return false;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,626 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Joomlaplugin;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as Plugin;
use VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\FileHelper;
/**
* Joomla Plugin Builder Class
*
* @since 3.2.0
*/
class Builder
{
/**
* Compiler Joomla Plugin Data Class
*
* @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
* Compiler Component
*
* @var Component
* @since 3.2.0
**/
protected Component $component;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Counter
*
* @var Counter
* @since 3.2.0
*/
protected Counter $counter;
/**
* Compiler Utilities Folder
*
* @var Folder
* @since 3.2.0
*/
protected Folder $folder;
/**
* Compiler Utilities File
*
* @var File
* @since 3.2.0
*/
protected File $file;
/**
* Compiler Utilities Files
*
* @var Files
* @since 3.2.0
*/
protected Files $files;
/**
* Constructor
*
* @param Plugin|null $plugin The compiler Joomla plugin data object.
* @param Component|null $component The component class.
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param EventInterface|null $event The compiler event api object.
* @param Counter|null $counter The compiler counter object.
* @param Folder|null $folder The compiler folder object.
* @param File|null $file The compiler file object.
* @param Files|null $files The compiler files object.
*
* @since 3.2.0
*/
public function __construct(?Plugin $plugin = null, ?Component $component = null,
?Config $config = null, ?Registry $registry = null,
?Dispenser $dispenser = null, ?EventInterface $event = null,
?Counter $counter = null, ?Folder $folder = null,
?File $file = null, ?Files $files = null)
{
$this->plugin = $plugin ?: Compiler::_('Joomlaplugin.Data');
$this->component = $component ?: Compiler::_('Component');
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->event = $event ?: Compiler::_('Event');
$this->counter = $counter ?? Compiler::_('Utilities.Counter');
$this->folder = $folder ?? Compiler::_('Utilities.Folder');
$this->file = $file ?? Compiler::_('Utilities.File');
$this->files = $files ?? Compiler::_('Utilities.Files');
}
/**
* Build the Plugins files, folders, url's and config
*
* @return void
* @since 3.2.0
*/
public function run()
{
if ($this->plugin->exists())
{
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$plugins = $this->plugin->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->event->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$plugins)
);
foreach ($plugins as $plugin)
{
if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name)
&& StringHelper::check(
$plugin->folder_name
))
{
// plugin path
$plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
// set the plugin paths
$this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path);
// make sure there is no old build
$this->folder->remove($plugin->folder_path);
// creat the main component folder
$this->folder->create($plugin->folder_path);
// set main class file
$fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.php',
'name' => $plugin->file_name . '.php',
'zip' => $plugin->file_name . '.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('MAINCLASS')
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
// set main xml file
$fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.xml',
'name' => $plugin->file_name . '.xml',
'zip' => $plugin->file_name . '.xml');
$this->file->write(
$fileDetails['path'],
$this->getXML($plugin)
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
// set install script if needed
if ($plugin->add_install_script)
{
$fileDetails = array('path' => $plugin->folder_path
. '/script.php',
'name' => 'script.php',
'zip' => 'script.php');
$this->file->write(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
Placefix::_h('INSTALLCLASS')
);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
// set readme if found
if ($plugin->addreadme)
{
$fileDetails = array('path' => $plugin->folder_path
. '/README.md',
'name' => 'README.md',
'zip' => 'README.md');
$this->file->write($fileDetails['path'], $plugin->readme);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
// set fields & rules folders if needed
if (isset($plugin->fields_rules_paths)
&& $plugin->fields_rules_paths == 2)
{
// create fields folder
$this->folder->create($plugin->folder_path . '/fields');
// create rules folder
$this->folder->create($plugin->folder_path . '/rules');
}
// set forms folder if needed
if (isset($plugin->form_files)
&& ArrayHelper::check(
$plugin->form_files
))
{
// create forms folder
$this->folder->create($plugin->folder_path . '/forms');
// set the template files
foreach ($plugin->form_files as $file => $fields)
{
// set file details
$fileDetails = array('path' => $plugin->folder_path
. '/forms/' . $file . '.xml',
'name' => $file . '.xml',
'zip' => 'forms/' . $file
. '.xml');
// build basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' . $this->config->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
foreach ($fields as $field_name => $fieldsets)
{
if (!$add_component_path)
{
foreach ($fieldsets as $fieldset => $field)
{
if (!$add_component_path
&& isset(
$plugin->fieldsets_paths[$file
. $field_name . $fieldset]
)
&& $plugin->fieldsets_paths[$file
. $field_name . $fieldset] == 1)
{
$add_component_path = true;
}
}
}
}
// only add if part of the component field types path is required
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
$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"';
$xml .= PHP_EOL . '>';
}
else
{
$xml .= PHP_EOL . '<form>';
}
// add the fields
foreach ($fields as $field_name => $fieldsets)
{
// check if we have an double fields naming set
$field_name_inner = '';
$field_name_outer = $field_name;
if (strpos((string) $field_name, '.') !== false)
{
$field_names = explode('.', (string) $field_name);
if (count((array) $field_names) == 2)
{
$field_name_outer = $field_names[0];
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
{
// default to the field set name
$label = $fieldset;
if (isset($plugin->fieldsets_label[$file . $field_name . $fieldset]))
{
$label = $plugin->fieldsets_label[$file . $field_name . $fieldset];
}
// add path to plugin rules and custom fields
if (isset($plugin->fieldsets_paths[$file . $field_name . $fieldset])
&& ($plugin->fieldsets_paths[$file . $field_name . $fieldset] == 2
|| $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3))
{
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{
$plugin->add_rule_path[$file . $field_name . $fieldset] =
'/plugins/' . strtolower((string) $plugin->group
) . '/' . strtolower((string) $plugin->code_name)
. '/rules';
}
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$plugin->add_field_path[$file . $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[$file . $field_name . $fieldset])
|| isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the plugin -->';
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"';
}
if (isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"';
}
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '">';
}
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset );
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
$this->file->write($fileDetails['path'], $xml);
$this->files->appendArray($plugin->key, $fileDetails);
// count the file created
$this->counter->file++;
}
}
// set SQL stuff if needed
if ($plugin->add_sql || $plugin->add_sql_uninstall)
{
// create SQL folder
$this->folder->create($plugin->folder_path . '/sql');
// create mysql folder
$this->folder->create(
$plugin->folder_path . '/sql/mysql'
);
// now set the install file
if ($plugin->add_sql)
{
$this->file->write(
$plugin->folder_path . '/sql/mysql/install.sql',
$plugin->sql
);
// count the file created
$this->counter->file++;
}
// now set the uninstall file
if ($plugin->add_sql_uninstall)
{
$this->file->write(
$plugin->folder_path
. '/sql/mysql/uninstall.sql',
$plugin->sql_uninstall
);
// count the file created
$this->counter->file++;
}
}
// creat the language folder path
$this->folder->create($plugin->folder_path . '/language');
// also creat the lang tag folder path
$this->folder->create(
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
);
// check if this lib has files
if (isset($plugin->files)
&& ArrayHelper::check($plugin->files))
{
// add to component files
foreach ($plugin->files as $file)
{
// set the path finder
$file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id;
$this->component->appendArray('files', $file);
}
}
// check if this lib has folders
if (isset($plugin->folders)
&& ArrayHelper::check($plugin->folders))
{
// add to component folders
foreach ($plugin->folders as $folder)
{
// set the path finder
$folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id;
$this->component->appendArray('folders', $folder);
}
}
// check if this plugin has urls
if (isset($plugin->urls)
&& ArrayHelper::check($plugin->urls))
{
// add to component urls
foreach ($plugin->urls as $n => &$url)
{
// should we add the local folder
if (isset($url['type']) && $url['type'] > 1
&& isset($url['url'])
&& StringHelper::check(
$url['url']
))
{
// set file name
$fileName = basename((string) $url['url']);
// get the file contents
$data = FileHelper::getContent(
$url['url']
);
// build sub path
if (strpos($fileName, '.js') !== false)
{
$path = '/js';
}
elseif (strpos($fileName, '.css') !== false)
{
$path = '/css';
}
else
{
$path = '';
}
// create sub media media folder path if not set
$this->folder->create(
$plugin->folder_path . $path
);
// set the path to plugin file
$url['path'] = $plugin->folder_path . $path
. '/' . $fileName; // we need this for later
// write data to path
$this->file->write($url['path'], $data);
// count the file created
$this->counter->file++;
}
}
}
}
}
}
}
/**
* get the plugin xml template
*
* @param object $module The plugin object
*
* @return string
* @since 3.2.0
*/
protected function getXML(object &$plugin): string
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="plugin" version="'
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
. strtolower((string) $plugin->group) . '" method="upgrade">';
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
. '</name>';
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
. '</version>';
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
. '_XML_DESCRIPTION</description>';
$xml .= Placefix::_h('MAINXML');
$xml .= PHP_EOL . '</extension>';
return $xml;
}
}

View File

@ -0,0 +1,886 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Joomlaplugin;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\PluginHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Joomla Plugin Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Joomla Plugins Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* 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 Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler Language object.
* @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)
{
$this->config = $config ?: Compiler::_('Config');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get the Joomla Plugin/s
*
* @param int|null $id the plugin id
*
* @return object|array|null if ID found it returns object, if no ID given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Plugin/s exists
*
* @param int|null $id the plugin id
*
* @return bool if ID found it returns true, if no ID given it returns true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Plugin
*
* @param int $id the plugin id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'g.name',
'e.name',
'e.head',
'e.comment',
'e.id',
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'group',
'extends',
'class_head',
'comment',
'class_id',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_plugin AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_group', 'g'
) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group')
. ' = ' . $this->db->quoteName('g.id') . ')'
);
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_class_extends', 'e')
. ' ON (' . $this->db->quoteName('a.class_extends') . ' = '
. $this->db->quoteName('e.id') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('u.joomla_plugin') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_files_folders_urls', 'f'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('f.joomla_plugin') . ')'
);
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
$query->where($this->db->quoteName('a.published') . ' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the plugin data
$plugin = $this->db->loadObject();
// tweak system to set stuff to the plugin domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$plugin->target_type = 'P|uG!n';
$plugin->key = $plugin->id . '_' . $plugin->target_type;
// update to point to plugin
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
// set version if not set
if (empty($plugin->plugin_version))
{
$plugin->plugin_version = '1.0.0';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_plugin',
'id' => (int) $id, 'type' => 'php');
// update the name if it has dynamic values
$plugin->name = $this->placeholder->update_(
$this->customcode->update($plugin->name)
);
// update the name if it has dynamic values
$plugin->code_name
= ClassfunctionHelper::safe(
$plugin->name
);
// set official name
$plugin->official_name = ucwords(
$plugin->group . ' - ' . $plugin->name
);
// set lang prefix
$plugin->lang_prefix = PluginHelper::safeLangPrefix(
$plugin->code_name,
$plugin->group
);
// set langPrefix
$this->config->lang_prefix = $plugin->lang_prefix;
// set plugin class name
$plugin->class_name
= PluginHelper::safeClassName(
$plugin->code_name,
$plugin->group
);
// set plugin install class name
$plugin->installer_class_name
= PluginHelper::safeInstallClassName(
$plugin->code_name,
$plugin->group
);
// set plugin folder name
$plugin->folder_name
= PluginHelper::safeFolderName(
$plugin->code_name,
$plugin->group
);
// set the zip name
$plugin->zip_name = $plugin->folder_name . '_v' . str_replace(
'.', '_', (string) $plugin->plugin_version
) . '__J' . $this->config->joomla_version;
// set plugin file name
$plugin->file_name = strtolower((string) $plugin->code_name);
// set plugin context
$plugin->context = $plugin->folder_name . '.' . $plugin->id;
// set official_name lang strings
$this->language->set(
$plugin->key, $this->config->lang_prefix, $plugin->official_name
);
// set some placeholder for this plugin
$this->placeholder->set('Plugin_name', $plugin->official_name);
$this->placeholder->set('PLUGIN_NAME', $plugin->official_name);
$this->placeholder->set('Plugin', ucfirst((string) $plugin->code_name));
$this->placeholder->set('plugin', strtolower((string) $plugin->code_name));
$this->placeholder->set('Plugin_group', ucfirst((string) $plugin->group));
$this->placeholder->set('plugin_group', strtolower((string) $plugin->group));
$this->placeholder->set('plugin.version', $plugin->plugin_version);
$this->placeholder->set('VERSION', $plugin->plugin_version);
$this->placeholder->set('plugin_version', str_replace(
'.', '_', (string) $plugin->plugin_version
));
// set description
$this->placeholder->set('DESCRIPTION', '');
if (!isset($plugin->description)
|| !StringHelper::check(
$plugin->description
))
{
$plugin->description = '';
}
else
{
$plugin->description = $this->placeholder->update_(
$this->customcode->update($plugin->description)
);
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_DESCRIPTION',
$plugin->description
);
// set description
$this->placeholder->set('DESCRIPTION', $plugin->description);
$plugin->description = '<p>' . $plugin->description . '</p>';
}
// get author name
$project_author = $this->config->project_author;
// we can only set these if the component was passed
$plugin->xml_description = "<h1>" . $plugin->official_name
. " (v." . $plugin->plugin_version
. ")</h1> <div style='clear: both;'></div>"
. $plugin->description . "<p>Created by <a href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started "
. Factory::getDate($plugin->created)->format("jS F, Y")
. "</small></p>";
// set xml discription
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION',
$plugin->xml_description
);
// update the readme if set
if ($plugin->addreadme == 1 && !empty($plugin->readme))
{
$plugin->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $plugin->readme))
);
}
else
{
$plugin->addreadme = 0;
unset($plugin->readme);
}
// open some base64 strings
if (!empty($plugin->main_class_code))
{
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode main_class_code.
$plugin->main_class_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->main_class_code)
)
),
$guiMapper
);
}
// set the head :)
if ($plugin->add_head == 1 && !empty($plugin->head))
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode head.
$plugin->head = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->head)
)
),
$guiMapper
);
}
elseif (!empty($plugin->class_head))
{
// base64 Decode head.
$plugin->head = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->class_head)
)
),
array(
'table' => 'class_extends',
'field' => 'head',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
unset($plugin->class_head);
// set the comment
if (!empty($plugin->comment))
{
// base64 Decode comment.
$plugin->comment = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->comment)
)
),
array(
'table' => 'class_extends',
'field' => 'comment',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
// start the config array
$plugin->config_fields = [];
// create the form arrays
$plugin->form_files = [];
$plugin->fieldsets_label = [];
$plugin->fieldsets_paths = [];
$plugin->add_rule_path = [];
$plugin->add_field_path = [];
// set global fields rule to default component path
$plugin->fields_rules_paths = 1;
// set the fields data
$plugin->fields = (isset($plugin->fields)
&& JsonHelper::check($plugin->fields))
? json_decode((string) $plugin->fields, true) : null;
if (ArrayHelper::check($plugin->fields))
{
// ket global key
$key = $plugin->key;
$dynamic_fields = array('fieldset' => 'basic',
'fields_name' => 'params',
'file' => 'config');
foreach ($plugin->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin'] != 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switchs
if ($plugin->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$plugin->fields_rules_paths = 2;
}
// set where to path is pointing
$plugin->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$plugin->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$plugin->add_rule_path[$unique] = $add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$plugin->add_field_path[$unique] = $add_field_path['path'];
}
}
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin'] != 1)
{
// load the form file
if (!isset($plugin->form_files[$form['file']]))
{
$plugin->form_files[$form['file']]
= [];
}
if (!isset($plugin->form_files[$form['file']][$form['fields_name']]))
{
$plugin->form_files[$form['file']][$form['fields_name']]
= [];
}
if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $plugin->key, $unique
);
// add the fields to the global form file builder
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
else
{
// load the config form
if (!isset($plugin->config_fields[$form['fields_name']]))
{
$plugin->config_fields[$form['fields_name']]
= [];
}
if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']]))
{
$plugin->config_fields[$form['fields_name']][$form['fieldset']]
= [];
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $plugin->key, $unique
);
// add the fields to the config builder
$plugin->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
}
else
{
unset($plugin->fields[$n]);
}
}
}
unset($plugin->fields);
// set files and folders
$this->filesFolders->set($plugin);
// add PHP in plugin install
$plugin->add_install_script = false;
$addScriptMethods = array('php_preflight',
'php_postflight',
'php_method');
$addScriptTypes = array('install', 'update',
'uninstall');
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset(
$plugin->{'add_' . $scriptMethod . '_'
. $scriptType}
)
&& $plugin->{'add_' . $scriptMethod . '_'
. $scriptType} == 1
&& StringHelper::check(
$plugin->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_'
. $scriptType;
$plugin->{$scriptMethod . '_' . $scriptType}
= $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $plugin->{$scriptMethod . '_'
. $scriptType}
)
)
),
$guiMapper
);
$plugin->add_install_script = true;
}
else
{
unset($plugin->{$scriptMethod . '_' . $scriptType});
$plugin->{'add_' . $scriptMethod . '_'
. $scriptType}
= 0;
}
}
}
// add_sql
if ($plugin->add_sql == 1
&& StringHelper::check($plugin->sql))
{
$plugin->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $plugin->sql))
);
}
else
{
unset($plugin->sql);
$plugin->add_sql = 0;
}
// add_sql_uninstall
if ($plugin->add_sql_uninstall == 1
&& StringHelper::check(
$plugin->sql_uninstall
))
{
$plugin->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->sql_uninstall)
)
);
}
else
{
unset($plugin->sql_uninstall);
$plugin->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($plugin->add_update_server == 1
&& StringHelper::check(
$plugin->update_server_url
))
{
$plugin->update_server_url = $this->placeholder->update_(
$this->customcode->update($plugin->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array('update_server', 'sales_server');
foreach ($serverArray as $server)
{
if ($plugin->{'add_' . $server} == 1
&& is_numeric(
$plugin->{$server}
)
&& $plugin->{$server} > 0)
{
// get the server protocol
$plugin->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $plugin->{$server}, 'id', 'protocol'
);
}
else
{
$plugin->{$server} = 0;
// only change this for sales server (update server can be added locally to the zip file)
if ('sales_server' === $server)
{
$plugin->{'add_' . $server} = 0;
}
$plugin->{$server . '_protocol'} = 0;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->set('lang_prefix', $_backup_langPrefix);
$this->placeholder->remove('Plugin_name');
$this->placeholder->remove('Plugin');
$this->placeholder->remove('plugin');
$this->placeholder->remove('Plugin_group');
$this->placeholder->remove('plugin_group');
$this->placeholder->remove('plugin.version');
$this->placeholder->remove('plugin_version');
$this->placeholder->remove('VERSION');
$this->placeholder->remove('DESCRIPTION');
$this->placeholder->remove('PLUGIN_NAME');
$this->data[$id] = $plugin;
return true;
}
}
return false;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.

View File

@ -2,7 +2,7 @@
/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 2022
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
@ -104,26 +104,19 @@ class Extractor
{
// get targets to search for
$lang_string_targets = array_filter(
$this->config->lang_string_targets, function ($get) use ($content) {
if (strpos($content, $get) !== false)
{
return true;
}
return false;
}
$this->config->lang_string_targets, fn($get): bool => strpos($content, (string) $get) !== false
);
// check if we should continue
if (ArrayHelper::check($lang_string_targets))
{
// insure string is not broken
$content = $this->placeholder->update($content, $this->placeholder->active);
$content = $this->placeholder->update_($content);
// reset some buckets
$lang_holders = array();
$lang_check = array();
$lang_only = array();
$js_text = array();
$sc_text = array();
$lang_holders = [];
$lang_check = [];
$lang_only = [];
$js_text = [];
$sc_text = [];
// first get the Joomla .JText._()
if (in_array('Joomla' . '.JText._(', $lang_string_targets))
{

Some files were not shown because too many files have changed in this diff Show More