summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc93
1 files changed, 49 insertions, 44 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc b/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc
index dd82ec9..9b832f3 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.pages.inc
@@ -18,25 +18,25 @@
function checklistapi_checklist_clear_confirm($form, &$form_state, $id) {
$checklist = checklistapi_checklist_load($id);
$form['#checklist'] = $checklist;
- return confirm_form(
- $form,
- t('Are you sure you want to clear %title saved progress?', array(
- '%title' => $checklist->title,
- )),
- $checklist->path,
- t('All progress details will be erased. This action cannot be undone.'),
- t('Clear'),
- t('Cancel')
- );
+ $question = t('Are you sure you want to clear %title saved progress?', array(
+ '%title' => $checklist->title,
+ ));
+ $description = t('All progress details will be erased. This action cannot be undone.');
+ $yes = t('Clear');
+ $no = t('Cancel');
+ return confirm_form($form, $question, $checklist->path, $description, $yes, $no);
}
/**
* Form submission handler for checklistapi_checklist_clear_confirm().
*/
function checklistapi_checklist_clear_confirm_submit($form, &$form_state) {
+ // If user confirmed, clear saved progress.
if ($form_state['values']['confirm']) {
$form['#checklist']->clearSavedProgress();
}
+
+ // Redirect back to checklist.
$form_state['redirect'] = $form['#checklist']->path;
}
@@ -53,12 +53,26 @@ function checklistapi_checklist_clear_confirm_submit($form, &$form_state) {
*/
function checklistapi_checklist_form($form, &$form_state, $id) {
$form['#checklist'] = $checklist = checklistapi_checklist_load($id);
+
+ $form['progress_bar'] = array(
+ '#type' => 'markup',
+ '#markup' => theme('checklistapi_progress_bar', array(
+ 'message' => ($checklist->hasSavedProgress()) ? t('Last updated @date by !user', array(
+ '@date' => $checklist->getLastUpdatedDate(),
+ '!user' => $checklist->getLastUpdatedUser(),
+ )) : ' ',
+ 'number_complete' => $checklist->getNumberCompleted(),
+ 'number_of_items' => $checklist->getNumberOfItems(),
+ 'percent_complete' => round($checklist->getPercentComplete()),
+ )),
+ );
if (checklistapi_compact_mode()) {
$form['#attributes']['class'] = array('compact-mode');
}
$form['compact_mode_link'] = array(
'#markup' => theme('checklistapi_compact_link'),
);
+
$form['checklistapi'] = array(
'#attached' => array(
'css' => array(drupal_get_path('module', 'checklistapi') . '/checklistapi.css'),
@@ -67,6 +81,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
'#tree' => TRUE,
'#type' => 'vertical_tabs',
);
+
// Loop through groups.
$num_autochecked_items = 0;
$groups = $checklist->items;
@@ -79,6 +94,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
if (!empty($group['#description'])) {
$form['checklistapi'][$group_key]['#description'] = filter_xss_admin($group['#description']);
}
+
// Loop through items.
foreach (element_children($group) as $item_key) {
$item = &$group[$item_key];
@@ -112,21 +128,8 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
$links = array();
foreach (element_children($item) as $link_key) {
$link = &$item[$link_key];
- $context = (!empty($link['#context'])) ? $link['#context'] : CHECKLISTAPI_LINK_CONTEXT_ANY;
- $show_link = FALSE;
- if ($context == CHECKLISTAPI_LINK_CONTEXT_ANY) {
- $show_link = TRUE;
- }
- elseif ($saved_item && $context == CHECKLISTAPI_LINK_CONTEXT_ITEM_CHECKED) {
- $show_link = TRUE;
- }
- elseif (!$saved_item && $context == CHECKLISTAPI_LINK_CONTEXT_ITEM_UNCHECKED) {
- $show_link = TRUE;
- }
- if ($show_link) {
- $options = (!empty($link['#options']) && is_array($link['#options'])) ? $link['#options'] : array();
- $links[] = l($link['#text'], $link['#path'], $options);
- }
+ $options = (!empty($link['#options']) && is_array($link['#options'])) ? $link['#options'] : array();
+ $links[] = l($link['#text'], $link['#path'], $options);
}
if (count($links)) {
$description .= '<div class="links">' . implode(' | ', $links) . '</div>';
@@ -142,6 +145,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
);
}
}
+
$form['actions'] = array(
'#access' => $user_has_edit_access,
'#type' => 'actions',
@@ -153,6 +157,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
),
'clear' => array(
'#access' => $checklist->hasSavedProgress(),
+ '#attributes' => array('class' => array('clear-saved-progress')),
'#href' => $checklist->path . '/clear',
'#title' => t('Clear saved progress'),
'#type' => 'link',
@@ -163,17 +168,16 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
// to prevent it from reappearing after saving the form. (Testing the request
// method may not be the "correct" way to accomplish this.)
if ($num_autochecked_items && $_SERVER['REQUEST_METHOD'] == 'GET') {
- drupal_set_message(t(
- format_plural(
- $num_autochecked_items,
- '%checklist found 1 unchecked item that was already completed and checked it for you. Save the form to record the change.',
- '%checklist found @num unchecked items that were already completed and checked them for you. Save the form to record the changes.'
- ),
- array(
- '%checklist' => $checklist->title,
- '@num' => $num_autochecked_items,
- )
- ), 'status');
+ $args = array(
+ '%checklist' => $checklist->title,
+ '@num' => $num_autochecked_items,
+ );
+ $message = format_plural(
+ $num_autochecked_items,
+ t('%checklist found 1 unchecked item that was already completed and checked it for you. Save the form to record the change.', $args),
+ t('%checklist found @num unchecked items that were already completed and checked them for you. Save the form to record the changes.', $args)
+ );
+ drupal_set_message($message, 'status');
}
return $form;
@@ -200,7 +204,7 @@ function checklistapi_checklist_form_submit($form, &$form_state) {
* can be set in the settings.php file.
*
* @return bool
- * TRUE when in compact mode, FALSE when in expanded mode.
+ * TRUE when in compact mode, or FALSE when in expanded mode.
*/
function checklistapi_compact_mode() {
return isset($_COOKIE['Drupal_visitor_checklistapi_compact_mode']) ? $_COOKIE['Drupal_visitor_checklistapi_compact_mode'] : variable_get('checklistapi_compact_mode', FALSE);
@@ -210,7 +214,8 @@ function checklistapi_compact_mode() {
* Menu callback: Sets whether the admin menu is in compact mode or not.
*
* @param string $mode
- * Valid values are 'on' and 'off'.
+ * (optional) The mode to set compact mode to. Accepted values are "on" and
+ * "off". Defaults to "off".
*/
function checklistapi_compact_page($mode = 'off') {
user_cookie_save(array('checklistapi_compact_mode' => ($mode == 'on')));
@@ -226,11 +231,11 @@ function theme_checklistapi_compact_link() {
$output = '<div class="compact-link">';
if (checklistapi_compact_mode()) {
$output .= l(
- t('Show descriptions'),
- request_path() . '/compact/off',
+ t('Show item descriptions'),
+ current_path() . '/compact/off',
array(
'attributes' => array(
- 'title' => t('Expand layout to include descriptions.'),
+ 'title' => t('Expand layout to include item descriptions.'),
),
'query' => drupal_get_destination(),
)
@@ -238,11 +243,11 @@ function theme_checklistapi_compact_link() {
}
else {
$output .= l(
- t('Hide descriptions'),
- request_path() . '/compact/on',
+ t('Hide item descriptions'),
+ current_path() . '/compact/on',
array(
'attributes' => array(
- 'title' => t('Compress layout by hiding descriptions.'),
+ 'title' => t('Compress layout by hiding item descriptions.'),
),
'query' => drupal_get_destination(),
)