Ejemplo n.º 1
0
/**
 * Prints information about a single attachment including download link, file
 * size, upload timestamp and an expandable preview for text and image file
 * types.
 * @param array $p_attachment An attachment arrray from within the array returned by the file_get_visible_attachments() function
 */
function print_bug_attachment($p_attachment)
{
    $t_show_attachment_preview = $p_attachment['preview'] && $p_attachment['exists'] && ($p_attachment['type'] == 'text' || $p_attachment['type'] == 'image');
    if ($t_show_attachment_preview) {
        $t_collapse_id = 'attachment_preview_' . $p_attachment['id'];
        global $g_collapse_cache_token;
        $g_collapse_cache_token[$t_collapse_id] = false;
        collapse_open($t_collapse_id);
    }
    print_bug_attachment_header($p_attachment);
    if ($t_show_attachment_preview) {
        echo lang_get('word_separator');
        collapse_icon($t_collapse_id);
        if ($p_attachment['type'] == 'text') {
            print_bug_attachment_preview_text($p_attachment);
        } else {
            if ($p_attachment['type'] === 'image') {
                print_bug_attachment_preview_image($p_attachment);
            }
        }
        collapse_closed($t_collapse_id);
        print_bug_attachment_header($p_attachment);
        echo lang_get('word_separator');
        collapse_icon($t_collapse_id);
        collapse_end($t_collapse_id);
    }
}
Ejemplo n.º 2
0
/**
 * Prints information about a single attachment including download link, file
 * size, upload timestamp and an expandable preview for text and image file
 * types.
 * If $p_security_token is null, a token will be generated with form_security_token().
 * If otherwise specified (i.e. not null), the parameter must contain
 * a valid security token, previously generated by form_security_token().
 * Use this to avoid performance issues when loading pages having many calls to
 * this function, such as print_bug_attachments_list().
 * @param array $p_attachment An attachment array from within the array returned by the file_get_visible_attachments() function.
 * @param mixed  $p_security_token Optional; null (default) or security token string.
 * @see form_security_token()
 * @return void
 */
function print_bug_attachment(array $p_attachment, $p_security_token = null)
{
    $t_show_attachment_preview = $p_attachment['preview'] && $p_attachment['exists'] && ($p_attachment['type'] == 'text' || $p_attachment['type'] == 'image');
    if ($t_show_attachment_preview) {
        $t_collapse_id = 'attachment_preview_' . $p_attachment['id'];
        global $g_collapse_cache_token;
        $g_collapse_cache_token[$t_collapse_id] = false;
        collapse_open($t_collapse_id);
    }
    # The same token is used for both links in the collapse section
    if (null === $p_security_token) {
        $p_security_token = form_security_token('bug_file_delete');
    }
    print_bug_attachment_header($p_attachment, $p_security_token);
    if ($t_show_attachment_preview) {
        echo lang_get('word_separator');
        collapse_icon($t_collapse_id);
        if ($p_attachment['type'] == 'text') {
            print_bug_attachment_preview_text($p_attachment);
        } else {
            if ($p_attachment['type'] === 'image') {
                print_bug_attachment_preview_image($p_attachment);
            }
        }
        collapse_closed($t_collapse_id);
        print_bug_attachment_header($p_attachment, $p_security_token);
        echo lang_get('word_separator');
        collapse_icon($t_collapse_id);
        collapse_end($t_collapse_id);
    }
}