Commit 59da7ea5 authored by TravisCarden's avatar TravisCarden

By TravisCarden: Made various small code and comment improvements.

parent f5b0d05b
......@@ -17,8 +17,8 @@
* Checklist API will register menu items and create permissions for each one.
*
* @return array
* An array of checklists. Each checklist is keyed by an arbitrary unique
* identifier. The corresponding multidimensional array describing the
* An array of checklist definitions. Each definition is keyed by an arbitrary
* unique identifier. The corresponding multidimensional array describing the
* checklist may contain the following key-value pairs:
* - #title: The title of the checklist.
* - #path: The Drupal path where the checklist will be accessed.
......@@ -79,8 +79,8 @@
* @see hook_checklistapi_checklist_info_alter()
*/
function hook_checklistapi_checklist_info() {
$checklists = array();
$checklists['example_checklist'] = array(
$definitions = array();
$definitions['example_checklist'] = array(
'#title' => t('Example checklist'),
'#path' => 'example-checklist',
'#description' => t('An example checklist.'),
......@@ -100,7 +100,7 @@ function hook_checklistapi_checklist_info() {
),
),
);
return $checklists;
return $definitions;
}
/**
......
......@@ -20,7 +20,7 @@ function checklistapi_checklist_clear_confirm($form, &$form_state, $id) {
$form['#checklist'] = $checklist;
return confirm_form(
$form,
t('Are you sure you want to clear %title progress?', array(
t('Are you sure you want to clear %title saved progress?', array(
'%title' => $checklist->title,
)),
$checklist->path,
......@@ -119,10 +119,9 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
}
// Get description.
$description = (isset($item['#description'])) ? '<p>' . $item['#description'] . '</p>' : '';
// Build links.
// Append links.
$links = array();
$link_keys = element_children($item);
foreach ($link_keys as $link_key) {
foreach (element_children($item) as $link_key) {
$link = &$item[$link_key];
$context = (!empty($link['#context'])) ? $link['#context'] : CHECKLISTAPI_LINK_CONTEXT_ANY;
$show_link = FALSE;
......
......@@ -13,8 +13,8 @@
* .
*/
function checklistapi_example_checklistapi_checklist_info() {
$checklists = array();
$checklists['example_checklist'] = array(
$definitions = array();
$definitions['example_checklist'] = array(
'#title' => t('Checklist API example'),
'#path' => 'admin/config/development/checklistapi-example',
'#description' => t('An example implementation of the Checklist API.'),
......@@ -195,7 +195,7 @@ function checklistapi_example_checklistapi_checklist_info() {
),
),
);
return $checklists;
return $definitions;
}
/**
......@@ -208,14 +208,14 @@ function checklistapi_example_checklistapi_checklist_info() {
* @link http://buytaert.net/drupal-learning-curve Dries Buytaert's Drupal learning curve @endlink
* .
*/
function checklistapi_example_checklistapi_checklist_info_alter(&$checklists) {
$checklists['example_checklist']['#help'] = t('<p>This checklist based on <a href="http://www.unleashedmind.com/files/drupal-learning-curve.png">sun\'s modification</a> of <a href="http://buytaert.net/drupal-learning-curve">Dries Buytaert\'s Drupal learning curve</a> is an example implementation of the <a href="http://drupal.org/project/checklistapi">Checklist API</a>.</p>');
$checklists['example_checklist']['i_kick_butt']['advanced_tasks']['#title'] = t('jQuery, Form API, theme and module development');
$checklists['example_checklist']['i_kick_butt']['advanced_tasks'] += $checklists['example_checklist']['i_kick_butt']['development'];
unset($checklists['example_checklist']['i_kick_butt']['development']);
$checklists['example_checklist']['i_kick_butt']['contribute_code']['#title'] = t('Contributing code, designs and patches back to Drupal contrib');
unset($checklists['example_checklist']['i_kick_butt']['chx_or_unconed']);
$checklists['example_checklist']['core_contributor'] = array(
function checklistapi_example_checklistapi_checklist_info_alter(&$definitions) {
$definitions['example_checklist']['#help'] = t('<p>This checklist based on <a href="http://www.unleashedmind.com/files/drupal-learning-curve.png">sun\'s modification</a> of <a href="http://buytaert.net/drupal-learning-curve">Dries Buytaert\'s Drupal learning curve</a> is an example implementation of the <a href="http://drupal.org/project/checklistapi">Checklist API</a>.</p>');
$definitions['example_checklist']['i_kick_butt']['advanced_tasks']['#title'] = t('jQuery, Form API, theme and module development');
$definitions['example_checklist']['i_kick_butt']['advanced_tasks'] += $definitions['example_checklist']['i_kick_butt']['development'];
unset($definitions['example_checklist']['i_kick_butt']['development']);
$definitions['example_checklist']['i_kick_butt']['contribute_code']['#title'] = t('Contributing code, designs and patches back to Drupal contrib');
unset($definitions['example_checklist']['i_kick_butt']['chx_or_unconed']);
$definitions['example_checklist']['core_contributor'] = array(
'#title' => t("I'm a core contributor"),
'contribute_core_code' => array(
'#title' => t('Contribute code and patches to Drupal core'),
......@@ -248,13 +248,13 @@ function checklistapi_example_checklistapi_checklist_info_alter(&$checklists) {
),
'security_performance' => array(
'#title' => t('Security audits, performance tuning.'),
'handbook_page_security' => $checklists['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_security'],
'handbook_page_performance' => $checklists['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_performance'],
'handbook_page_security' => $definitions['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_security'],
'handbook_page_performance' => $definitions['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_performance'],
),
);
unset($checklists['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_security']);
unset($checklists['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_performance']);
$checklists['example_checklist']['core_maintainer'] = array(
unset($definitions['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_security']);
unset($definitions['example_checklist']['i_kick_butt']['advanced_tasks']['handbook_page_performance']);
$definitions['example_checklist']['core_maintainer'] = array(
'#title' => t("I'm trustworthy for core maintainership"),
'add_sub_system' => array(
'#title' => t('Rewrite or add a Drupal core sub-system.'),
......@@ -266,7 +266,7 @@ function checklistapi_example_checklistapi_checklist_info_alter(&$checklists) {
'#title' => t('Core branch maintainer'),
),
);
$checklists['example_checklist']['know_every_bit_of_core'] = array(
$definitions['example_checklist']['know_every_bit_of_core'] = array(
'#title' => t('I know every bit of core'),
'im_chx' => array(
'#title' => t(
......@@ -275,7 +275,7 @@ function checklistapi_example_checklistapi_checklist_info_alter(&$checklists) {
),
),
);
$checklists['example_checklist']['understand_all_core_patch_implications'] = array(
$definitions['example_checklist']['understand_all_core_patch_implications'] = array(
'#title' => t('I understand all implications of a core patch'),
'im_chuck_norris' => array(
'#title' => t("I'm Chuck Norris."),
......
......@@ -151,36 +151,37 @@ class ChecklistapiChecklist {
// Loop through groups.
foreach ($values as $group_key => $group) {
if (!is_array($group)) {
continue;
}
// Loop through items.
if (is_array($group)) {
foreach ($group as $item_key => $item) {
$old_item = (!empty($this->savedProgress[$item_key])) ? $this->savedProgress[$item_key] : 0;
if ($item == 1) {
// Item is checked.
$progress['#completed_items']++;
if ($old_item) {
// Item was previously checked. Use saved value.
$new_item = $old_item;
}
else {
// Item is newly checked. Set new value.
$new_item = array(
'#completed' => $time,
'#uid' => $user->uid,
);
$changed_items_counter++;
}
foreach ($group as $item_key => $item) {
$old_item = (!empty($this->savedProgress[$item_key])) ? $this->savedProgress[$item_key] : 0;
if ($item == 1) {
// Item is checked.
$progress['#completed_items']++;
if ($old_item) {
// Item was previously checked. Use saved value.
$new_item = $old_item;
}
else {
// Item is unchecked.
$new_item = 0;
if ($old_item) {
// Item was previously checked.
$changed_items_counter++;
}
// Item is newly checked. Set new value.
$new_item = array(
'#completed' => $time,
'#uid' => $user->uid,
);
$changed_items_counter++;
}
}
else {
// Item is unchecked.
$new_item = 0;
if ($old_item) {
// Item was previously checked.
$changed_items_counter++;
}
$progress[$item_key] = $new_item;
}
$progress[$item_key] = $new_item;
}
}
......
......@@ -9,8 +9,8 @@
* Implements hook_checklistapi_checklist_info().
*/
function checklistapi_test_checklistapi_checklist_info() {
$checklists = array();
$checklists['test_checklist'] = array(
$definitions = array();
$definitions['test_checklist'] = array(
'#title' => t('Checklist API test'),
'#path' => 'admin/config/development/checklistapi-test',
'#description' => t('A test checklist.'),
......@@ -59,5 +59,5 @@ function checklistapi_test_checklistapi_checklist_info() {
'#weight' => 'invalid',
),
);
return $checklists;
return $definitions;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment