diff --git a/4a.-JCB-Demo-Component-Directory,-Folders-and-Files.md b/4a.-JCB-Demo-Component-Directory,-Folders-and-Files.md index e6b64cc..5c9c535 100644 --- a/4a.-JCB-Demo-Component-Directory,-Folders-and-Files.md +++ b/4a.-JCB-Demo-Component-Directory,-Folders-and-Files.md @@ -6,7 +6,7 @@ The directories, folders and files of the JCB Demo component, found in the JCB D * JCB functionalities and features used while building the Demo component * JCB interaction with the Joomla! API -The last bullet above is extremely important to understand as we stated earlier in this manual. There will be directories, files and code in the JCB Demo component package you may ponder over; you will wonder how they got there. JCB leverages the Joomla! API to accomplish this. To see how this is done, go the extra mile and cross reference everything as was done here. The process is tedious, but will reinforce your understanding of the many areas of JCB where the component's directories and files were created automatically by JCB. This includes the code snippets you have written and placed in various areas of the JCB component during the build process while using JCB's standard features and functionality to enhance your code snippet, but did not write any code for. This process also allows one to understand that JCB reuses and extends Joommla!'s core code classes, methods and properties supplied by the Joomla! API as much as possible. +Take notice of the last bullet above. There will be directories, files and code in the JCB Demo component package you may ponder over; you will wonder how they got there. JCB leverages the Joomla! API to accomplish this. To see how this is done, go the extra mile and cross reference everything as was done here. The process is tedious, but will reinforce your understanding of the many areas of JCB where the component's directories and files were created automatically by JCB. This includes the code snippets you have written and placed in various areas of the JCB component during the build process while using JCB's standard features and functionality to enhance your code snippet, but did not write any code for. This process also allows one to understand that JCB reuses and extends Joommla!'s core code classes, methods and properties supplied by the Joomla! API as much as possible. The JCB Demo component analysis presented in this chapter will introduce you to a typical MVC directory structure and the files it contains, for a component that should be easy to understand. However, the MVC paradigm applies to all components, regardless of complexity, so the analysis can be applied to any component. As the complexity increases, developing with the following greatly reduces the time required to build a component: @@ -19,7 +19,7 @@ The JCB Demo component analysis presented in this chapter will introduce you to * Developer Tools in Chrome is a very good source for debugging JavaScript in real time with features similar to NetBeans debugger. * Developer Tools in Chrome has many other features to assist you with debugging and tweaking your site on-the fly. -There are [many other possibilities](https://docs.joomla.org/Setting_up_your_workstation_for_web_development), especially with the IDE, but this combination integrates well, and much of its features are native to the applications comprising it. This also applies to any other components used as examples in the videos and chapters accompanying them in this manual. Keep in mind as you progress through them the complexity of the components being shown as examples will increase. The directory tree will look more complex, and contain many additional files. However, they all share one thing in common which is the [MVC Paradigm](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller); all follow its basic directory structure and naming conventions, including the files contained in it. This also includes the locations of the files. The code and necessary constructs specific to a Model, View or Controller for each to function and interconnect with each other and the Joomla! API at the most basic level are common to all, if developed using the MVC paradigm in its strictest sense. +There are [many other possibilities](https://docs.joomla.org/Setting_up_your_workstation_for_web_development), especially with the IDE, but this combination integrates well, and much of its features are native to the applications comprising it. This also applies to any other components used as examples in the videos and chapters accompanying them in this manual. The directory tree will also look more complex as you progress, and contain many additional files. However, they all share one thing in common which is the [MVC Paradigm](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller); all follow its basic directory structure and naming conventions, including the files contained in the dorectories. This also includes the locations of the files. The code and necessary constructs specific to a Model, View or Controller for each to function and interconnect with each other and the Joomla! API at the most basic level are common to all, if developed using the MVC paradigm in its strictest sense. Unzip com_demo_v2_0_0__J3.zip and using the shell or command line, list its directories, sub-directories and all the files contained in them, by changing to the root of the directory and typing for example dir > demoDirectory.txt /s if using the Microsoft Windows command line. Other operating systems have a similar command in their shell. Then, browse through the directories and files using the file manager for your operating system like Windows Explorer or better yet, an Integrated Development Environment (IDE) like [NetBeans](https://netbeans.org/) or a similar Integrated Development Environment (IDE) with native XDEBUG and GitHub functionality. An IDE is recommended since it has many features facilitating this analysis. Some of these include: @@ -271,28 +271,89 @@ Beneath the directory structure and files presented next you will find a short e \router.php *** 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. + +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. *** -**index.html** - File containing one line of HTML that blocks directory view. Must be in root of each folder. - +Note, the following applies in general for any component: +**index.html** +File containing one line of HTML that blocks directory view. Must be in root of each folder. + **All Joomla class files must begin with this code:** // No direct access to this file defined('_JEXEC') or die('Restricted access'); *** ## \demo.php -### Let's look at JCB, Editing the Site View; it's where the site view entry point for the JCB Demo component is defined. This code has been inserted in JCB for you. You will need to supply code for your own components and this code provides the basic elements required. You can: +### 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. +Super Administrator can: * Login to admin as super administrator and create a look. * Add a registered user. * Create a Joomla! menu item for the demo component looks, access should be registered. -* Update the look table with the registered user is in created by and modified by columns if the table. -* Login as the registered user, select the looks option from the main menu +Registered Users can: +* Edit the look record in the demo_look table, reusing the adminForm form to do so +- The registered user id of the logged in user must match the created_by value for it to display. +* First, login as the registered user and select the looks option from the main menu * The site view looks displays with the Name and Description of the registered user's look and an edit toolbar underneath. -* Clicking the edit toolbar displays the admin view look, displaying only the actions defined for that user group. +* Click the edit toolbar and display the admin view look, displaying only the form actions defined for that user group. - Save - Save and Close - Close -* The More button is also enabled allowing entry of the additional fields on the form. +* The More button was enabled in the JCB demo +- This allowing entry of the additional fields on the form. -\ and the admin view look so one can edit their own look record in the looks_demo table. By default, access control is only allowed for the super administrator. If access is given in Joomla!'s ACL to the JCB Demo component for let's say the registered group of Joomla! users, the edit button will display below the name and description. This brings up the matter of access control levels or ACL in Joomla! See the text after the view for information or you will not be able to edit a look despite owning it. +Let's look at the code behind all of this.admin view look so one can edit their own look record in the looks_demo table. By default, access control is only allowed for the super administrator. If access is given in Joomla!'s ACL to the JCB Demo component for let's say the registered group of Joomla! users, the edit button will display below the name and description. This brings up the matter of access control levels or ACL in Joomla! See the text after the view for information or you will not be able to edit a look despite owning it. + +If you use Chrome's More Tools - Developer Tools, use the element pointer to find this on the page: + +