-
Notifications
You must be signed in to change notification settings - Fork 1
Islandora Module File Structure and Naming
tl;dr: Filenames should contain lowercase characters and PHP files (except templates) should use underscores to separate words in the filename.
Consistent file naming augments the ability of developers to quickly identify the location of code within modules. The Drupal community has not documented a set of conventions related to naming files although a pattern of file naming can be observed by reviewing major contributed modules.
Modules meant for public distribution are generally expected to include a README.txt and LICENCE.txt file. README.txt files should follow the Drupal README.txt conventions found here (http://api.drupal.org/api/drupal/README.txt/7).
PHP code will generally be placed in (.module, .install, .test, .inc, .php) files. Unless otherwise specified filenames should contain only lowercase characters and should use underscores to separate words in the filename.
Good: islandora_something.inc
Bad: IslandoraSomething.inc
Hook implementations and functions providing API-like interfaces or extensively used utilities should be placed in the .module file of a module. Typically it is expected that if this module is part of the islandora ecosystem (meant for wide distribution and to be branded as part of islandora) the modules name will be prefixed with islandora.
Include files (*.inc) should contain all other PHP code (non-template or install files) and should be placed in a subdirectory of the module named includes. The module name should not be used as a prefix in the filename; it is redundant. These rules apply to all .inc files, including files containing classes. To further aid file discovery, include files may contain a file-type extension helper such as .form or .pages if the file contains menu callbacks grouped together (example: admin.form.inc).
Good: includes/mime_detect.inc
Bad: includes/islandora_mime_detect.inc
Good: includes/upload_form.inc
Better: includes/upload.form.inc
Template files should have an extension of .tpl.php and should be placed in the theme subdirectory of the module. Template filenames should include the module name with words separated by a hyphen/dash (example: islandora-object.tpl.php).
The theme subdirectory can also contain files like *.theme.inc, where any theme related functions can be implemented (preprocess theme hooks, etc). Functions included in *.theme.inc files should only be used by the theme system, if a function is used else where it should be moved to a different file.
Good: theme/module_name.theme.inc
Bad: includes/theme.inc
Good: theme/islandora-object.tpl.php
Bad: theme/islandora_object.tpl.php
The following table summarizes where files are expected to be.
General purpose subdirectories may be used for related files of a similar mime type or purpose, such as images (example: *.png or *.tiff files in ../images). Unless otherwise specified filenames should contain only lowercase characters and should use underscores to separate words in the filename.
Modules should always prefix the names of their CSS files with the module name; for example, system-menus.css rather than simply menus.css. Themes can override module-supplied CSS files based on their filenames, and this prefixing helps prevent confusing name collisions for theme developers. See drupal_get_css() where the overrides are performed. Also, if the direction of the current language is right-to-left (Hebrew, Arabic, etc.), the function will also look for an RTL CSS file and append it to the list. The name of this file should have an '-rtl.css' suffix. For example, a CSS file called 'mymodule-name.css' will have a 'mymodule-name-rtl.css' file added to the list, if exists in the same directory. This CSS file should contain overrides for properties which should be reversed or otherwise different in a right-to-left display. CSS files can use dashes to separate words as well as underscores.
Good: css/islandora_admin.css
Bad: css/IslandoraAdmin.css
Good: css/islandora-admin.css
Better: css/islandora.admin.css
Please refer to the Module documentation guidelines (http://drupal.org/node/161085) For more information on conventions.