Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Frankenstyle: Difference between revisions

From MoodleDocs
(Removing core_log, it was a mistake)
m (Protected "Frankenstyle": Developer Docs Migration ([Edit=Allow only administrators] (indefinite)))
 
(19 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{Template:Migrated|newDocId=/general/development/policies/codingstyle/frankenstyle}}
'Frankenstyle component names' refers to the naming convention that is used to uniquely identify a Moodle plugin based on the type of plugin and its name.  They are used throughout the Moodle code (with a notable exception being the css class names in the themes).
'Frankenstyle component names' refers to the naming convention that is used to uniquely identify a Moodle plugin based on the type of plugin and its name.  They are used throughout the Moodle code (with a notable exception being the css class names in the themes).


Martin Dougiamas invented the word 'frankenstyle' to describe this naming system which was invented by Petr Skoda.
Martin Dougiamas invented the word 'frankenstyle' to describe this naming system which was invented by Petr Škoda.


== Format ==
== Format ==
Line 14: Line 15:
== Plugin types ==
== Plugin types ==


{| class="nicetable"
See [[Plugin types]] page for the list of all supported plugin types in Moodle and their frankenstyle prefix.
 
To get a definitive list in your version of Moodle 2.x, use a small Moodle script with <tt>print_object(get_plugin_types());</tt>.
 
== Core subsystems ==
 
Subsystems in Moodle are not plugins themselves but can be referred to using '''core_xxx''' where xxx is the subsystem name as defined in get_core_subsystems(). 
 
You can see these being used in the @package parameter in phpdocs, or in the [[Web_services_Roadmap|webservice function names]]. Core subsystems can provide own strings via a file stored in <tt>lang/en/{subsystemname}.php</tt>. Some of them have a dedicated location with libraries, autoloaded classes and other resources.
 
 
{| class="wikitable"
|-
|-
! Plugin type
! Core subsystem
! Frankenstyle prefix
! Frankenstyle component name
! Moodle path
! Location
|-
|-
| [[Activity modules]]
| Access
| mod
| core_access
| /mod
|
|-
|-
| [[Admin reports]]
| Administration
| report
| core_admin
| /admin/report
| /admin
|-
|-
| [[Admin tools]]
| Antivirus
| tool
| core_antivirus
| /admin/tool
| /lib/antivirus
|-
|-
| [[Assignment types]]
| Authentication
| assignment
| core_auth
| /mod/assignment/type
|-
| [[Authentication plugins]]
| auth
| /auth
| /auth
|-
|-
| [[Blocks]]
| Conditional availability
| block
| core_availability
| /blocks
| /availability
|-
|-
| Core subsystems
| Backup and restore
| core
| core_backup
| / (not a true plugin, see below for details)
| /backup/util/ui
|-
|-
| [[Course formats]]
| Badges
| format
| core_badges
| /course/format
| /badges
|-
|-
| [[Course reports]]
| Blocks
| coursereport
| core_block
| /course/report
| /blocks
|-
|-
| [[Database fields]]
| Blogging
| datafield
| core_blog
| /mod/data/field
| /blog
|-
|-
| [[Database presets]]
| Bulk users operations
| datapreset
| core_bulkusers
| /mod/data/preset
|
|-
|-
| [[Editors]]
| Caching
| editor
| core_cache
| /lib/editor
| /cache
|-
|-
| [[Enrolment plugins]]
| Calendar
| enrol
| core_calendar
| /enrol
| /calendar
|-
|-
| [[Filters]]
| Cohorts
| filter
| core_cohort
| /filter
| /cohort
|-
|-
| [[Gradebook export]]
| Comment
| gradeexport
| core_comment
| /grade/export
| /comment
|-
|-
| [[Gradebook import]]
| Competency based education
| gradeimport
| core_competency
| /grade/import
| /competency
|-
|-
| [[Gradebook reports]]
| Completion
| gradereport
| core_completion
| /grade/report
| /completion
|-
|-
| [[Grading methods]]
| Countries
| gradingform
| core_countries
| /grade/grading/form
|
|-
|-
| [[Local plugins]]
| Course
| local
| core_course
| /local
| /course
|-
|-
| [[Messaging consumers]]
| Currencies
| message
| core_currencies
| /message/output
|
|-
|-
| [[Mnet services]]
| Database transfer
| mnetservice
| core_dbtransfer
| /mnet/service
|
|-
|-
| [[Plagiarism plugins]]
| Debugging
| plagiarism
| core_debug
| /plagiarism
|
|-
|-
| [[Portfolio plugins]]
| Text editors
| portfolio
| core_editor
| /portfolio
| /lib/editor
|-
|-
| [[Question behaviours]]
| Education fields
| qbehaviour
| core_edufields
| /question/behaviour
|  
|-
|-
| [[Question formats]]
| Enrol
| qformat
| core_enrol
| /question/format
| /enrol
|-
|-
| [[Question types]]
| Error reporting
| qtype
| core_error
| /question/type
|
|-
|-
| [[Quiz reports]]
| Favourites
| quiz
| core_favourites
| /mod/quiz/report
| /favourites
|-
|-
| [[Repository plugins]]
| repository
| /repository
|-
|-
| [[SCORM reports]]
| File picker
| scormreport
| core_filepicker
| /mod/scorm/report
|
|-
|-
| [[Themes]]
| Files management
| theme
| core_files
| /theme
| /files
|-
|-
| [[User profile fields]]
| User filtering
| profilefield
| core_filters
| /user/profile/field
|
|-
|-
| [[Webservice protocols]]
| Forms
| webservice
| core_form
| /webservice
| /lib/form
|-
|-
| [[Workshop allocation strategies]]
| Grades
| workshopallocation
| core_grades
| /mod/workshop/allocation
| /grade
|-
|-
| [[Workshop evaluation plugins]]
| Advanced grading
| workshopeval
| core_grading
| /mod/workshop/eval
| /grade/grading
|-
|-
| [[Workshop grading forms]]
| Groups
| workshopform
| core_group
| /mod/workshop/form
| /group
|}
 
 
To get a definitive list in your version of Moodle 2.x, use a small Moodle script with <tt>print_object(get_plugin_types());</tt>.
 
== Core subsystems ==
 
Subsystems in Moodle are not plugins themselves but can be referred to using '''core_xxx''' where xxx is the subsystem name as defined in get_core_subsystems(). 
 
You can see these being used in the @package parameter in phpdocs, or in the [[Web_services_Roadmap|webservice function names]].
 
 
{| class="nicetable"
|-
! Core subsystem
! Frankenstyle component name
|-
| Access
| core_access
|-
|-
| Conditional availability
| Help
| core_condition
| core_help
|
|-
|-
| Comment
| Hub
| core_comment
| core_hub
|
|-
|-
| Completion
| IMS CC
| core_completion
| core_imscc
|
|-
|-
| Course
| Installer
| core_course
| core_install
|
|-
|-
| Enrol
| ISO 6392
| core_enrol
| core_iso6392
|
|-
|-
| Files
| Language pack configuration
| core_files
| core_langconfig
|
|-
|-
| Forms
| License
| core_form
| core_license
|
|-
|-
| Grade
| Maths library
| core_grade
| core_mathslib
|
|-
|-
| Groups
| Media
| core_group
| core_media
|
|-
|-
| Messages
| Messaging
| core_message
| core_message
| /message
|-
| MIME types
| core_mimetypes
|-
|-
| Mnet
| MNet
| core_mnet
| core_mnet
| /mnet
|-
|-
| My home page
| Dashboard
| core_my
| core_my
| /my
|-
|-
| Notes
| User notes
| core_notes
| core_notes
| /notes
|-
| Page types
| core_pagetype
|
|-
| Pictures and icons
| core_pix
|
|-
| Plagiarism
| core_plagiarism
| /plagiarism
|-
| Plugins management
| core_plugin
|
|-
| Portfolio
| core_portfolio
| /portfolio
|-
| Privacy
| core_privacy
|/privacy
|-
| Course publishing
| core_publish
| /course/publish
|-
| Question bank engine
| core_question
| /question
|-
|-
| Ratings
| Ratings
| core_rating
| core_rating
| /rating
|-
|-
| Role
| Site registration
| core_role
| core_register
| /admin/registration
|-
| Repository
| core_repository
| /repository
|-
|-
| RSS
| RSS
| core_rss
| core_rss
| /rss
|-
|-
| Tag
| Roles
| core_role
| /admin/roles
|-
| Global search
| core_search
| /search
|-
| Tabular data display/download (deprecated)
| core_table
|
|-
| Tagging
| core_tag
| core_tag
| /tag
|-
| Timezones
| core_timezones
|
|-
|-
| User
| User
| core_user
| core_user
| /user
|-
| User key
| core_userkey
|
|-
|-
| Web service
| Web service
| core_webservice
| core_webservice
| /webservice
|}
|}


Line 240: Line 304:


Frankenstyle component names are used in:
Frankenstyle component names are used in:
=== Function names ===
All plugin functions must start with full frankenstyle prefix. For backwards compatibility modules may also use '''modulename_''' as prefix.
=== Class names ===
* All the component classes must sit under the classes ([[Automatic_class_loading|auto-loaded]]) directory, belonging to their frankenstyle namespace and having a natural name, ex: \mod_forum\example.
* The use of class names using the frankenstyle prefix is now deprecated (see [[Coding style#Namespaces|Coding style]]), ex: mod_forum_example.
=== Constants ===
All plugin constants must start with uppercase frankenstyle prefix, example MOD_FORUM_XXXX.


=== Table names ===
=== Table names ===
Line 248: Line 325:


Examples: mdl_'''local_coolreport''', mdl_'''local_coolreport'''_users
Examples: mdl_'''local_coolreport''', mdl_'''local_coolreport'''_users
=== Plugin configuration table ===
In the '''config_plugins''' table, column '''plugin''', the frankenstyle name is used.


=== Capabilities ===
=== Capabilities ===
Line 262: Line 343:


=== Renderers ===
=== Renderers ===
=== Module Subplugins ===
It is possible to extend modules without having to change the basic module's code. See [[Subplugins]] for details.


=== Other places (TODO) ===
=== Other places (TODO) ===
Line 271: Line 356:


Please add more as they come up.
Please add more as they come up.
== Naming theme variants ==
Themes that are principally derivatives of some other theme, should be named in a way that clearly implies they are variants, not upgrades, of the parent theme. The format of the name should follow and extend the standard component naming format. So for example themes based on Boost, if they want to mention the word "boost" in the component name, should be named like
theme_boost_something
for example theme_boost_spring, theme_boost_summer, theme_boost_shiny etc. Indeed they can be named just like
theme_something
as there is no need to repeat the parent name (e.g. theme_spring, theme_summer, theme_shiny). The point and reasoning behind this is to avoid confusion - for example a theme_boost2 looks like a new version of the official Boost theme and as such is not a good name for a contributed theme.


==See also==
==See also==


* [[Plugins]]
* [[Plugins]]
* [[Subplugins]]
* [[Core APIs]]
* [[Core APIs]]
* [[Automatic class loading]]


[[Category:Plugins]]
[[Category:Plugins]]

Latest revision as of 10:03, 28 July 2022

Important:

This content of this page has been updated and migrated to the new Moodle Developer Resources. The information contained on the page should no longer be seen up-to-date.

Why not view this page on the new site and help us to migrate more content to the new site!

'Frankenstyle component names' refers to the naming convention that is used to uniquely identify a Moodle plugin based on the type of plugin and its name. They are used throughout the Moodle code (with a notable exception being the css class names in the themes).

Martin Dougiamas invented the word 'frankenstyle' to describe this naming system which was invented by Petr Škoda.

Format

Frankenstyle component names have a prefix and then a folder name, separated by an underscore.

  1. The prefix is determined by the type of plugin. For example, the prefix for an activity module is mod.
  2. The name is the folder name of the plugin, always lower case. For example, the name for Quiz is quiz.

So the frankenstyle component name for the quiz module is mod_quiz.

Plugin types

See Plugin types page for the list of all supported plugin types in Moodle and their frankenstyle prefix.

To get a definitive list in your version of Moodle 2.x, use a small Moodle script with print_object(get_plugin_types());.

Core subsystems

Subsystems in Moodle are not plugins themselves but can be referred to using core_xxx where xxx is the subsystem name as defined in get_core_subsystems().

You can see these being used in the @package parameter in phpdocs, or in the webservice function names. Core subsystems can provide own strings via a file stored in lang/en/{subsystemname}.php. Some of them have a dedicated location with libraries, autoloaded classes and other resources.


Core subsystem Frankenstyle component name Location
Access core_access
Administration core_admin /admin
Antivirus core_antivirus /lib/antivirus
Authentication core_auth /auth
Conditional availability core_availability /availability
Backup and restore core_backup /backup/util/ui
Badges core_badges /badges
Blocks core_block /blocks
Blogging core_blog /blog
Bulk users operations core_bulkusers
Caching core_cache /cache
Calendar core_calendar /calendar
Cohorts core_cohort /cohort
Comment core_comment /comment
Competency based education core_competency /competency
Completion core_completion /completion
Countries core_countries
Course core_course /course
Currencies core_currencies
Database transfer core_dbtransfer
Debugging core_debug
Text editors core_editor /lib/editor
Education fields core_edufields
Enrol core_enrol /enrol
Error reporting core_error
Favourites core_favourites /favourites
File picker core_filepicker
Files management core_files /files
User filtering core_filters
Forms core_form /lib/form
Grades core_grades /grade
Advanced grading core_grading /grade/grading
Groups core_group /group
Help core_help
Hub core_hub
IMS CC core_imscc
Installer core_install
ISO 6392 core_iso6392
Language pack configuration core_langconfig
License core_license
Maths library core_mathslib
Media core_media
Messaging core_message /message
MIME types core_mimetypes
MNet core_mnet /mnet
Dashboard core_my /my
User notes core_notes /notes
Page types core_pagetype
Pictures and icons core_pix
Plagiarism core_plagiarism /plagiarism
Plugins management core_plugin
Portfolio core_portfolio /portfolio
Privacy core_privacy /privacy
Course publishing core_publish /course/publish
Question bank engine core_question /question
Ratings core_rating /rating
Site registration core_register /admin/registration
Repository core_repository /repository
RSS core_rss /rss
Roles core_role /admin/roles
Global search core_search /search
Tabular data display/download (deprecated) core_table
Tagging core_tag /tag
Timezones core_timezones
User core_user /user
User key core_userkey
Web service core_webservice /webservice

Usage

Frankenstyle component names are used in:

Function names

All plugin functions must start with full frankenstyle prefix. For backwards compatibility modules may also use modulename_ as prefix.

Class names

  • All the component classes must sit under the classes (auto-loaded) directory, belonging to their frankenstyle namespace and having a natural name, ex: \mod_forum\example.
  • The use of class names using the frankenstyle prefix is now deprecated (see Coding style), ex: mod_forum_example.

Constants

All plugin constants must start with uppercase frankenstyle prefix, example MOD_FORUM_XXXX.

Table names

All table names for a plugin must begin with its frankenstyle name (after the standard Moodle table prefix).

(The exception to this rule is Moodle activities which (for historical reasons) do not have mod_ in front of the plugin name)

Examples: mdl_local_coolreport, mdl_local_coolreport_users

Plugin configuration table

In the config_plugins table, column plugin, the frankenstyle name is used.

Capabilities

All capabilities for a plugin use the frankenstyle name, except with a / instead of a _.

Example: mod/quiz:viewattempt

Language files

The main language file for each plugin (with the notable exception of activity modules) is the frankenstyle component name.

Examples: /blocks/participants/lang/en/block_participants.php

Renderers

Module Subplugins

It is possible to extend modules without having to change the basic module's code. See Subplugins for details.

Other places (TODO)


Please add more as they come up.

Naming theme variants

Themes that are principally derivatives of some other theme, should be named in a way that clearly implies they are variants, not upgrades, of the parent theme. The format of the name should follow and extend the standard component naming format. So for example themes based on Boost, if they want to mention the word "boost" in the component name, should be named like

theme_boost_something

for example theme_boost_spring, theme_boost_summer, theme_boost_shiny etc. Indeed they can be named just like

theme_something

as there is no need to repeat the parent name (e.g. theme_spring, theme_summer, theme_shiny). The point and reasoning behind this is to avoid confusion - for example a theme_boost2 looks like a new version of the official Boost theme and as such is not a good name for a contributed theme.

See also