Introduction
Hello everyone, in this article I will try to briefly tell about the components that make up the CMS architecture, there are a lot of them (I think they all don’t fit in the article), controllers, modules, plugins and css, js files connection.
The basis of KodiCMS is
Kohana framework version 3.3.2 . The core of the system is the “kodicms” module, which contains the main logic of operation and is expanded with the help of observers (modules) through plug-ins and modules.
The list of modules that were developed for CMS:
- API - Working with AJAX requests, supports GET, POST, PUT, DELETE request types. Answer in json or HTML format
- Behavior - expanding the behavior of frontend pages
- Dashboard - desktop and everything connected with it
- Datasource - the basis for creating data partitions (using it created sections Hybrid data , Categories , Document rating ), switchable
- elFinder - file manager, disable
- Email, Email _Queue - sending mail, bulk mailing, Email sections in Backend and tasks for the task manager, disabled
- FileSystem - classes for working with FS
- Installer - System Installer
- KodiCMS - System Core
- Navigation - Navigating Backend
- Page_Parts - Parts of the pages (Linked to the Pages module via the Observer ), disabled
- Pages - the module of the site pages, theoretically disabled
- Plugins - module plug-ins, organizes the expansion of the system plug-ins, switchable
- Reflinks - assistant for generating temporary links, for example, Recall a password or Confirmation of registration
- Scheduler - Calendar for Backend, as well as task manager Cron, disabled
- Search - site search, contains a full-text search driver, the list can be supplemented with its own drivers
- Sidebar , disabled
- Snippet - a module for organizing pieces of code that can be inserted into a template, also used by the “Widget” module for widget templates, which can be disabled
- Tags - the organization of tags in the module of the page and the Hybrid data, disconnected
- Update - system update module, disabled
- Users - system users, ACL
- Widget - Widgets, blocks placed on the site pages, display any information that is disabled.
*
disableable - disabling is possible in
application / init.php .
')
In addition to the modules developed by me, there are standard modules and third-party development in the system.
- Assets - for organizing CSS, JavaScript
- Breadcrumbs - generation of breadcrumbs, used by the “Breadcrumbs” widget
- Captcha
- Minion - used by the task manager to run scheduled tasks
- Pagination
KodiCMS module
The main CMS module, namely, it expands the standard Kohana functional, contains basic controllers for working with
Backend , configs, helpers, etc.
Settings
There are several types of settings storage in the system:
- File configs
- A table in the database to override file configs (cached)
- Separate table for storing plug-in information (Cached)
- Storing user information User_Meta (for example, the set and location of widgets on the desktop), as in Wordpress and Bitrix, SugarCRM, etc. (Cached)
Each module, as well as the system plug-in, can
override or add new parameters to the config file, so it was decided to use them for storing data that could be supplemented by a third-party developer in its module or plug-in, therefore the data for:
Those. when creating a plug-in, if you need to add a menu item (sitemap.php), a new section in the backend (datasources.php), expand access rights to new controllers (permissions.php) or add a new task to the
scheduler (jobs.php) it creates config file.
Controllers
The system controller has several levels of abstraction:
- Empty System_Controller controller
- Security controller of access control System_Security <System_Controller
- Template controller responsible for the page templates System_Template <System_Security
- Backend System_Backend <System_Template controller, from which all controllers are inherited for access to which authorization is required. This controller connects all the necessary css, javascript, etc.
- Frontend System_Frontend <System_Template controller, from which all controllers are inherited for access to which authorization is not needed. (Authorization, Recall Password, Error Page)
- Media controller for searching media files (sss, js, etc.) in all modules and plugins in the media folder, i.e. if in the plugin you create the media / css folder and put the css file in it (test.css), then you can access it as cms / media / css / test.css
- The System_API <System_Ajax controller API is mainly used for ajax (GET, POST, PUT, DELETE) requests, and actions in the controller also come in several types of get_ ..., post_ ..., put_ ..., delete_ ..., depending on what type of request comes in.
- Front controller for frontend pages.
Long ago, I talked about such a structure at the office. forum
kohana , maybe this post will seem useful to someone.
Frontend controller
The route for this controller is the last one on the list. When the controller is called, the page is searched by URL (
requests are cached ), then the page type is checked, the page is checked for access, widgets, parts of the page and other extensions are connected to the HTML template for the admin (for the admin, the ability to create a toolbar through View, as in fashionable CMS like Bitrix, Wordpress, etc.), caching on the browser side and specifying the page type (in the
slug field in the page settings you can specify the extension, for example,
rss.xml and the output will be with the appropriate Content-Type) .
I drew a diagram of the path that passes the request when calling the frontend controller, the scheme is a bit confusing and the main thing is not to get lost in the arrows and find Request.

Organization of media (css, js, less, image) files
The main media files of the system are located in the cms / media folder.
The main stylesheet file css / common.css is compiled from
LESS files and third-party libraries, including
Twitter Bootstrap ,
Font-Awesome, and others, recompiled when you turn on
the Less plugin and make changes to the
less / common.less file , which is also the main one.
The main JavaScript file is
js / backend.js (it will probably be described in a future article).
To connect
css and
js in templates, the
Assets module is used, which was slightly modified, namely, the package manager
Assets_Package was written , which will allow
grouping media files into packages . It can also be used in the frontend for quick connection of libraries, as well as in widgets.
Each module and plug-in in the system can also have a media folder with a similar structure and can be connected to the controller as cms / media / .... without specifying the name of the module, files are searched through Kohana :: find_file and therefore the paths of finding files are cached.
Also, when requesting a backend controller, it searches for the javascript file for it
cms / media / js / controller / controller_name.jsModules and Plugins
In addition to the standard features of the modules (and plug-ins including), support for the installation has been added to them.
At the moment of the installer launch, the installer searches and calls into each module of the
install / observers.php file, at the moment the system is installed, the installer goes through all the modules and
checks for the presence of the
install / schema.sql files , and then
install / dump.sql and after the launch of
install / install.phpSince plugins have the ability to
activate and
deactivate , then
install.php ,
uninstall.php ,
install / drop.sql , as well as in the
frontend.php and
backend.php files are added for them, which work in the same way as
init.php , but are connected in Frontend / Backend.
Otherwise, the work of plug-ins is no different from standard Kohana modules.
PSIn the previous article I forgot to mention that there is a plugin repository for KodiCMS:
github.com/KodiCMS , you can also see it in the
backend .
In the next article I would like to tell about the device of one of the modules or several modules, either to show an example of the implementation of a simple site or describe the capabilities of the section "
Hybrid Data ".
In general, if you are interested in learning something, write, I will try to tell you.