-
Notifications
You must be signed in to change notification settings - Fork 61
Architecture
Spuds edited this page Jan 26, 2023
·
2 revisions
DEVELOPER DOCUMENTATION > ARCHITECTURE
- Controllers
- sources/controllers and sources/admin (for admin area)
- they contain the action handlers, the functions/methods with naming pattern: action_xxx()
- makes permission checks, data sanitation and validation, processing, initializes contextual data and templates
- should not make queries
- should not send in $context data for use of other functions than templates
- should use helper functions for specialized (sub)tasks
- retrieves data to send for templates.
- Utilities, helpers, database work
- sources/subs, mainly. Also list_xxx() functions, helpers in controller files, classes in /subs.
- should be the only level which contains queries.
- should only use the widely available globals, i.e. $modSettings, $user_info (avoided if possible though), $smcFunc.
- only a few specialized functions should use $context: those which are dedicated to be controller helpers, with the only role to fill $context. (i.e. prepareContextXxx())
- Templates
- use $context, the contextual data, to fill and present the output.
- may further manipulate the data to render it in the desired format. (i.e. standardTime(), relativeTime(), comma_format())
- should not contain or do almost anything else. (i.e. no queries, no superglobals, only a few globals)
Execution flow is mainly this:
index.php
- Dispatcher class
- forwards to the right action handler: a controller function/method. (action_something())
- the action handler may be a menu-based handler or directly an action handler
- the menus will forward to the appropriate controller-function/method according to selection.
- the controller function/method:
- makes permissions checks
- sanitizes/validates data (or sends for sanitization/validation)
- may use helpers (i.e. list_xxx())
- .subs model-type functions (i.e. getTopicInfo()) or classes
- sets the template/sub-template.
- the controller function/method:
- passes control to the template rendering
(examples)
/controllers/MergeTopics.controller.php
- handles action=mergetopics
- functions correspond to subactions, i.e.: action_done() corresponds to action=mergetopics;sa=done /templates/MergeTopics.template.php
- corresponding sub-template i.e. template_merge_done()
/subs/Topic.subs.php
- database work, low-level functions, utilities, related to Topics.
- (optional) camelCasedFunctionNames()
/subs/XmlArray.class.php
- class Xml_Array
/admin/ManageAttachments.php
- corresponds to the admin area (i.e. manageattachments)
- methods correspond to sub-actions, i.e. action_browse() for ?action=admin;area=manageattachments;sa=browse
Architecture
- Architecture
- [Coding Standards](Coding Standards)
- [Database Layer](Database layer)
- MVC
- Release
Functions and Variables
- About $user_info variable
- About the createList() function.
- About [Template Layers](Template layers).
- About [is_activated](is activated) values.
Customization
- [Create a theme](Make a new theme)
- [Create an Addon](Create an Addon)
GitHub