Commit 0ece8a82 authored by TravisCarden's avatar TravisCarden

By TravisCarden: Made minor code and comment improvements.

parent faea88b6
...@@ -76,17 +76,16 @@ function checklistapi_checklist_form($form, &$form_state, $id) { ...@@ -76,17 +76,16 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
$form['checklistapi'][$group_key]['#description'] = filter_xss_admin($group['#description']); $form['checklistapi'][$group_key]['#description'] = filter_xss_admin($group['#description']);
} }
// Loop through items. // Loop through items.
$item_keys = element_children($group); foreach (element_children($group) as $item_key) {
foreach ($item_keys as $item_key) {
$item = &$group[$item_key]; $item = &$group[$item_key];
$saved_item = !empty($checklist->savedProgress[$item_key]) ? $checklist->savedProgress[$item_key] : 0; $saved_item = !empty($checklist->savedProgress[$item_key]) ? $checklist->savedProgress[$item_key] : 0;
// Build title. // Build title.
$title = filter_xss($item['#title']); $title = filter_xss($item['#title']);
if ($saved_item) { if ($saved_item) {
// Prepend completion details. // Append completion details.
$user = user_load($saved_item['#uid']); $user = user_load($saved_item['#uid']);
$title .= t( $title .= t(
' <span class="completion-details">- Completed @time by !user</a>', '<span class="completion-details"> - Completed @time by !user</a>',
array( array(
'@time' => format_date($saved_item['#completed'], 'short'), '@time' => format_date($saved_item['#completed'], 'short'),
'!user' => theme('username', array('account' => $user)), '!user' => theme('username', array('account' => $user)),
...@@ -104,7 +103,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) { ...@@ -104,7 +103,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
// Get description. // Get description.
$description = ''; $description = '';
if (!checklistapi_compact_mode() && isset($item['#description'])) { if (!checklistapi_compact_mode() && isset($item['#description'])) {
$description = '<p>' . $item['#description'] . '</p>'; $description = '<p>' . filter_xss_admin($item['#description']) . '</p>';
} }
// Append links. // Append links.
$links = array(); $links = array();
...@@ -126,11 +125,13 @@ function checklistapi_checklist_form($form, &$form_state, $id) { ...@@ -126,11 +125,13 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
$links[] = l($link['#text'], $link['#path'], $options); $links[] = l($link['#text'], $link['#path'], $options);
} }
} }
$description .= '<div class="links">' . implode(' | ', $links) . '</div>'; if (count($links)) {
$description .= '<div class="links">' . implode(' | ', $links) . '</div>';
}
// Compile the list item. // Compile the list item.
$form['checklistapi'][$group_key][$item_key] = array( $form['checklistapi'][$group_key][$item_key] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $title, '#title' => filter_xss($title),
'#description' => filter_xss_admin($description), '#description' => filter_xss_admin($description),
'#default_value' => $default_value, '#default_value' => $default_value,
'#disabled' => !($user_has_edit_access = $checklist->userHasAccess('edit')), '#disabled' => !($user_has_edit_access = $checklist->userHasAccess('edit')),
......
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