Updated 4a. JCB Demo Component Directory, Folders and Files (markdown)

Joseph Geller
2018-09-27 09:48:00 -05:00
parent 8506cab20e
commit 0c7f9c6062

@@ -272,7 +272,7 @@ Beneath the directory structure and files presented next you will find a short e
*** ***
Always keep in mind, JCB is doing most of the tasks related to items below referring to Joomla directories, files, classes, methods and properties. You do not have to, for example, put an index.html file in the root of every directory; you are not required to add the check for direct access to the file; you do not have to write code for the admin or site views unless you extend JCB with your own custom code. Always keep in mind, JCB is doing most of the tasks related to items below referring to Joomla directories, files, classes, methods and properties. You do not have to, for example, put an index.html file in the root of every directory; you are not required to add the check for direct access to the file; you do not have to write code for the admin or site views unless you extend JCB with your own custom code.
Some of the links below and seen previously in this document may be outdated and many Joomla! classes in use have early origins and are stated as such in the documentation. Locations of class files vary by release, and finding them and reviewing the code within each is made a bit more elusive with Joomla! 4 namespace changes but the standardization is worth it. There is current backwards compatibility and hence, lists of aliases do exist as we shall see next. Some of the links below and seen previously in this document may be outdated and many Joomla! classes in use have early origins and are stated as such in the documentation. Locations of class files vary by release, and finding them and reviewing the code within each is made a bit more elusive with Joomla! 4 namespace changes but the standardization is worth it. There is current backwards compatibility and hence, lists of aliases do exist as seen next.
There is a class map of aliases for classes that do not conform to Joomla 4! namespace naming convention. The file at \libraries\classmap.php should be consulted when writing your own components. The path on the right has the current locations along with the new standard naming convention aliased to it on the left. There are a few more areas where this occurs that is included below the list. Be aware that if for example, if the class method is indicated as JLoader::registerAlias('JControllerLegacy', '\\Joomla\\CMS\\MVC\\Controller\\BaseController', '5.0'), the physical path in Joomal! version 3.8.12 is \libraries\src\Application\BaseController.php. The Joomla! class in the file in this example is named BaseController which extends JObject. There is a class map of aliases for classes that do not conform to Joomla 4! namespace naming convention. The file at \libraries\classmap.php should be consulted when writing your own components. The path on the right has the current locations along with the new standard naming convention aliased to it on the left. There are a few more areas where this occurs that is included below the list. Be aware that if for example, if the class method is indicated as JLoader::registerAlias('JControllerLegacy', '\\Joomla\\CMS\\MVC\\Controller\\BaseController', '5.0'), the physical path in Joomal! version 3.8.12 is \libraries\src\Application\BaseController.php. The Joomla! class in the file in this example is named BaseController which extends JObject.
*** ***
@@ -285,7 +285,7 @@ File containing one line of HTML that blocks directory view. Must be in root of
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
*** ***
## \demo.php ## \demo.php
Let's look at the JCB Demo component using the admin area of Joomla!, signed in as a Super Administrator. JCB's Editing the Site View in the admin area of the site is where you add the code for the site view entry point for the JCB Demo component, /demo.php. This code has been inserted for you. You will need to supply code for your own components and the code in the JCB Demo component provides the basic elements for any component allowing CRUD (Create, Read, Update Delete) on database table records, in this case, look. Sign in as a Super Administrator to the admin area. JCB's Editing the Site View in the admin area of the site is where you add the code for the site view entry point for the JCB Demo component; its path is /demo.php. This code has been inserted for you. You will need to supply code for your own components and the code in the JCB Demo component provides the basic elements for any component allowing CRUD (Create, Read, Update Delete) on database table records, in this case, look.
Super Administrator can: Super Administrator can:
* Login to admin as super administrator and create a look. * Login to admin as super administrator and create a look.
@@ -294,7 +294,7 @@ Super Administrator can:
Registered Users can: Registered Users can:
* Edit the look record in the demo_look table, reusing the adminForm form to do so. To display, the registered user id of the logged in user must match the created_by value in the record. * Edit the look record in the demo_look table, reusing the adminForm form to do so. To display, the registered user id of the logged in user must match the created_by value in the record.
* Login as the registered user and select the looks option from the main menu * Login as the registered user and select the looks option from the main menu.
* Observe the site view looks displays with the Name and Description of the registered user's look and an edit toolbar underneath. * Observe the site view looks displays with the Name and Description of the registered user's look and an edit toolbar underneath.
* Click the edit toolbar and display the admin view look, displaying only the buttons representing the form actions defined for that user group which are Save, Save and Close, Close. * Click the edit toolbar and display the admin view look, displaying only the buttons representing the form actions defined for that user group which are Save, Save and Close, Close.
* Click the More button, enabled when the record was entered by the Super Administrator using the admin area of the site. This allows the Registered User to access additional fields on the form. * Click the More button, enabled when the record was entered by the Super Administrator using the admin area of the site. This allows the Registered User to access additional fields on the form.
@@ -306,19 +306,25 @@ By default, the site view looks is not authorized for any user besides the Super
* Looks (Site) Access Allowed * Looks (Site) Access Allowed
* Looks Edit Own Allowed * Looks Edit Own Allowed
The first option only allows access to the site. The view will display a look but that's all. The second allows access and therefore all looks will display and can be accessed (but not edited) as long as the third access is also granted. The fourth allows editing the look if the user's id matches the one in the look_demo table. record More details on the Joomla! ACL on this can be seen in [this video](https://www.youtube.com/watch?v=gWjQjdhYqXI&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=36). The first option only allows access to the site. The view will display a look but that's all. The second allows access and therefore all looks will display and can be accessed (but not edited) as long as the third access is also granted. The fourth allows editing the look if the user's id matches the one in the look_demo table. More details about the Joomla! ACL on this can be seen in [this video](https://www.youtube.com/watch?v=gWjQjdhYqXI&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=36).
There is a caveat in the demo that must be taken into consideration. From the admin area of the site, main menu option Selecting the Components, Component Builder, Dynamic Gets, Looks, Tweak option you must add the Filter: Be sure you add a filter using the admin area of the site, main menu option, Selecting the Components, Component Builder, Dynamic Gets, Looks, Tweak option:
* Where Table Key a.created_by equal = $this->user->id * Where Table Key a.created_by equal = $this->user->id
This Tweak to the Dynamic Get in JCB for the Demo component site view looks Dynamic Get, getListQuery extends it to only include records from the table that are created by the user having the same id as the current user, available from the site view looks $this variable, user id element in the form. The change takes effect once you use JCB to compile the component and install it again using the Joomla! extension installer. The same Tweak is required in the site view looking Dynamic Get, getItem. This Tweak to the Dynamic Get in JCB for the Demo component site view looks, Dynamic Get, getListQuery, extends it to only include records from the table that were created by the user having the same id as the current user. This is available from the site view looks, $this variable, user id form element. The change takes effect once you use JCB to compile the component and install it again using the Joomla! extension installer. The same Tweak is required in the site view looking Dynamic Get, getItem.
Doing the above also ensures only certain actions are allowed for certain users. In our case, a Registered User should only be allowed to: Doing the above also ensures only certain actions are allowed for certain users. In our case, a Registered User should only be allowed to:
* Save * Save
* Save and Close * Save and Close
* Close * Close
The filter only allows them to edit their own look records. Super Administrators by default are allowed all actions on the admin view. Performing the previous instructions also restricts a Registered user's actions to display only the Save, Save and Close, and Close buttons. If you add more permissions, more actions and hence more buttons will be allowed such as save and copy. Experiment with the JCB Demo component Joomla! ACL permissions and you can see the effect on what edit buttons appear since components do not need to be compiled using JCB to change these settings.
The filter allows them to edit only their own look records in the demo_look table. Login to the site area as a Super Administrator to see all records in the admin view. Performing the previous instructions also restricts a Registered User's actions to display only the following buttons in the looking view:
* Save
* Save and Close
* Close buttons
If you add more permissions, more actions and hence more buttons will be allowed such as save and copy. Change the JCB Demo component Joomla! ACL permissions and you can see the effect on what edit buttons appear immediately since components do not need to be compiled by JCB for these settings to change.
Continuing with the edit functionality: Continuing with the edit functionality:
* Edit the look record in the demo_look table. It is important you understand this is reusing the admin look edit look at the form tag in the source of the page using your browser (Chrome - Developer tools). * Edit the look record in the demo_look table. It is important you understand this is reusing the admin look edit look at the form tag in the source of the page using your browser (Chrome - Developer tools).