By TravisCarden: Made checklist progress bar update dynamically.
[project/checklistapi.git] / checklistapi.api.php
1 <?php
2
3 /**
4 * @file
5 * Hooks provided by the Checklist API module.
6 */
7
8 /**
9 * @addtogroup hooks
10 * @{
11 */
12
13 /**
14 * Define all checklists provided by the module.
15 *
16 * Any number of checklists can be defined in an implementation of this hook.
17 * Checklist API will register menu items and create permissions for each one.
18 *
19 * @return array
20 * An array of checklist definitions. Each definition is keyed by an arbitrary
21 * unique identifier. The corresponding multidimensional array describing the
22 * checklist may contain the following key-value pairs:
23 * - #title: The title of the checklist.
24 * - #path: The Drupal path where the checklist will be accessed.
25 * - #description: (optional) A brief description of the checklist for its
26 * corresponding menu item.
27 * - #help: (optional) User help to be displayed in the "System help" block
28 * via hook_help().
29 * - #menu_name: (optional) The machine name of a menu to place the checklist
30 * into (e.g. "main-menu" or "navigation"). If this is omitted, Drupal will
31 * try to infer the correct menu placement from the specified path.
32 * - #weight: (optional) A floating point number used to sort the list of
33 * checklists before being output. Lower numbers appear before higher
34 * numbers.
35 * - Any number of arrays representing groups of items, to be presented as
36 * vertical tabs. Each group is keyed by an arbitrary identifier, unique in
37 * the scope of the checklist. The corresponding multimensional array
38 * describing the group may contain the following key-value pairs:
39 * - #title: The title of the group, used as the vertical tab label.
40 * - #description: (optional) A description of the group.
41 * - #weight: (optional) A floating point number used to sort the list of
42 * groups before being output. Lower numbers appear before higher numbers.
43 * - Any number of arrays representing checklist items. Each item is keyed
44 * by an arbitrary identifier, unique in the scope of the checklist. The
45 * corresponding multimensional array describing the item may contain the
46 * following key-value pairs:
47 * - #title: The title of the item.
48 * - #description: (optional) A description of the item, for display
49 * beneath the title.
50 * - #default_value: (optional) The default checked state of the
51 * item--TRUE for checked or FALSE for unchecked. Defaults to FALSE.
52 * This is useful for automatically checking items that can be
53 * programmatically tested (e.g. a module is installed or a variable has
54 * a certain value).
55 * - #weight: (optional) A floating point number used to sort the list of
56 * items before being output. Lower numbers appear before higher
57 * numbers.
58 * - Any number of arrays representing links. Each link is keyed by an
59 * arbitrary unique identifier. The corresponding multimensional array
60 * describing the link may contain the following key-value pairs:
61 * - #text: The link text.
62 * - #path: The link path.
63 * - #options: (optional) An associative array of additional options
64 * used by the l() function.
65 * - #weight: (optional) A floating point number used to sort the list
66 * of items before being output. Lower numbers appear before higher
67 * numbers.
68 *
69 * For a working example, see checklistapi_example.module.
70 *
71 * @see checklistapi_example_checklistapi_checklist_info()
72 * @see hook_checklistapi_checklist_info_alter()
73 */
74 function hook_checklistapi_checklist_info() {
75 $definitions = array();
76 $definitions['example_checklist'] = array(
77 '#title' => t('Example checklist'),
78 '#path' => 'example-checklist',
79 '#description' => t('An example checklist.'),
80 '#help' => t('<p>This is an example checklist.</p>'),
81 'example_group' => array(
82 '#title' => t('Example group'),
83 '#description' => t('<p>Here are some example items.</p>'),
84 'example_item_1' => array(
85 '#title' => t('Example item 1'),
86 'example_link' => array(
87 '#text' => t('Example.com'),
88 '#path' => 'http://www.example.com/',
89 ),
90 ),
91 'example_item_2' => array(
92 '#title' => t('Example item 2'),
93 ),
94 ),
95 );
96 return $definitions;
97 }
98
99 /**
100 * Alter checklist definitions.
101 *
102 * This hook is invoked by checklistapi_get_checklist_info(). The checklist
103 * definitions are passed in by reference. Additional checklists may be added,
104 * or existing checklists may be altered or removed.
105 *
106 * @param array $definitions
107 * The multidimensional array of checklist definitions returned by
108 * hook_checklistapi_checklist_info().
109 *
110 * For a working example, see checklistapi_example.module.
111 *
112 * @see checklistapi_get_checklist_info()
113 * @see hook_checklistapi_checklist_info()
114 */
115 function hook_checklistapi_checklist_info_alter(array &$definitions) {
116 // Add an item.
117 $definitions['example_checklist']['example_group']['new_item'] = array(
118 'title' => t('New item'),
119 );
120 // Add a group.
121 $definitions['example_checklist']['new_group'] = array(
122 '#title' => t('New group'),
123 );
124 // Move an item.
125 $definitions['example_checklist']['new_group']['example_item_1'] = $definitions['example_checklist']['example_group']['example_item_1'];
126 unset($definitions['example_checklist']['example_group']['example_item_1']);
127 // Remove an item.
128 unset($definitions['example_checklist']['example_group']['example_item_2']);
129 }
130
131 /**
132 * @} End of "addtogroup hooks".
133 */