Пример #1
0
/**
 * Prints the list of visible attachments belonging to a given bug.
 * @param int $p_bug_id ID of the bug to print attachments list for
 */
function print_bug_attachments_list($p_bug_id)
{
    $t_attachments = file_get_visible_attachments($p_bug_id);
    $t_attachments_count = count($t_attachments);
    echo "\n<ul>";
    foreach ($t_attachments as $t_attachment) {
        echo "\n<li>";
        print_bug_attachment($t_attachment);
        echo "\n</li>";
    }
    echo "\n</ul>";
}
Пример #2
0
function print_bug_attachments_list($p_bug_id)
{
    $t_attachments = file_get_visible_attachments($p_bug_id);
    $t_attachments_count = count($t_attachments);
    $i = 0;
    $image_previewed = false;
    foreach ($t_attachments as $t_attachment) {
        $t_file_display_name = string_display_line($t_attachment['display_name']);
        $t_filesize = number_format($t_attachment['size']);
        $t_date_added = date(config_get('normal_date_format'), $t_attachment['date_added']);
        if ($image_previewed) {
            $image_previewed = false;
            echo '<br />';
        }
        if ($t_attachment['can_download']) {
            $t_href_start = '<a href="' . string_attribute($t_attachment['download_url']) . '">';
            $t_href_end = '</a>';
            $t_href_clicket = " [<a href=\"file_download.php?file_id={$t_attachment['id']}&amp;type=bug\" target=\"_blank\">^</a>]";
        } else {
            $t_href_start = '';
            $t_href_end = '';
            $t_href_clicket = '';
        }
        if (!$t_attachment['exists']) {
            print_file_icon($t_file_display_name);
            echo '&#160;<span class="strike">' . $t_file_display_name . '</span>' . lang_get('word_separator') . '(' . lang_get('attachment_missing') . ')';
        } else {
            echo $t_href_start;
            print_file_icon($t_file_display_name);
            echo $t_href_end . '&#160;' . $t_href_start . $t_file_display_name . $t_href_end . $t_href_clicket . ' (' . $t_filesize . ' ' . lang_get('bytes') . ') ' . '<span class="italic">' . $t_date_added . '</span>';
        }
        if ($t_attachment['can_delete']) {
            echo '&#160;[';
            print_link('bug_file_delete.php?file_id=' . $t_attachment['id'] . form_security_param('bug_file_delete'), lang_get('delete_link'), false, 'small');
            echo ']';
        }
        if ($t_attachment['exists']) {
            if (FTP == config_get('file_upload_method') && $t_attachment['exists']) {
                echo ' (' . lang_get('cached') . ')';
            }
            if ($t_attachment['preview'] && $t_attachment['type'] == 'text') {
                $c_id = db_prepare_int($t_attachment['id']);
                $t_bug_file_table = db_get_table('mantis_bug_file_table');
                echo "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\nfunction swap_content( span ) {\ndisplayType = ( document.getElementById( span ).style.display == 'none' ) ? '' : 'none';\ndocument.getElementById( span ).style.display = displayType;\n}\n\n -->\n </script>";
                echo " <span id=\"hideSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('show_content') . "</a>]</span>";
                echo " <span style='display:none' id=\"showSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('hide_content') . "</a>]";
                echo "<pre>";
                /** @todo Refactor into a method that gets contents for download / preview. */
                switch (config_get('file_upload_method')) {
                    case DISK:
                        if ($t_attachment['exists']) {
                            $v_content = file_get_contents($t_attachment['diskfile']);
                        }
                        break;
                    case FTP:
                        if (file_exists($t_attachment['exists'])) {
                            file_get_contents($t_attachment['diskfile']);
                        } else {
                            $ftp = file_ftp_connect();
                            file_ftp_get($ftp, $t_attachment['diskfile'], $t_attachment['diskfile']);
                            file_ftp_disconnect($ftp);
                            $v_content = file_get_contents($t_attachment['diskfile']);
                        }
                        break;
                    default:
                        $query = "SELECT *\n\t                  \t\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\t            \t\t\tWHERE id=" . db_param();
                        $result = db_query_bound($query, array($c_id));
                        $row = db_fetch_array($result);
                        $v_content = $row['content'];
                }
                echo htmlspecialchars($v_content);
                echo "</pre></span>\n";
            }
            if ($t_attachment['can_download'] && $t_attachment['preview'] && $t_attachment['type'] == 'image') {
                $t_preview_style = 'border: 0;';
                $t_max_width = config_get('preview_max_width');
                if ($t_max_width > 0) {
                    $t_preview_style .= ' max-width:' . $t_max_width . 'px;';
                }
                $t_max_height = config_get('preview_max_height');
                if ($t_max_height > 0) {
                    $t_preview_style .= ' max-height:' . $t_max_height . 'px;';
                }
                $t_preview_style = 'style="' . $t_preview_style . '"';
                $t_title = file_get_field($t_attachment['id'], 'title');
                $t_image_url = $t_attachment['download_url'] . '&amp;show_inline=1' . form_security_param('file_show_inline');
                echo "\n<br />{$t_href_start}<img alt=\"{$t_title}\" {$t_preview_style} src=\"{$t_image_url}\" />{$t_href_end}";
                $image_previewed = true;
            }
        }
        if ($i != $t_attachments_count - 1) {
            echo "<br />\n";
            $i++;
        }
    }
}
            ?>
	</td>
</tr>
<?php 
        }
        # profile description
        ?>
<tr class="print">
	<td class="print-category">
		<?php 
        echo sprintf(lang_get('label'), $t_lang_attached_files);
        ?>
	</td>
	<td class="print" colspan="5">
		<?php 
        $t_attachments = file_get_visible_attachments($t_id);
        $t_first_attachment = true;
        $t_path = config_get_global('path');
        foreach ($t_attachments as $t_attachment) {
            if ($t_first_attachment) {
                $t_first_attachment = false;
            } else {
                echo '<br />';
            }
            $c_filename = string_display_line($t_attachment['display_name']);
            $c_download_url = htmlspecialchars($t_attachment['download_url']);
            $c_filesize = number_format($t_attachment['size']);
            $c_date_added = date($t_date_format, $t_attachment['date_added']);
            echo $c_filename . ' (' . $c_filesize . ' ' . lang_get('bytes') . ') <span class="italic-small">' . $c_date_added . '</span><br />' . string_display_links($t_path . $c_download_url);
            if ($t_attachment['preview'] && $t_attachment['type'] == 'image' && $f_type_page == 'html') {
                echo '<br /><img src="', $c_download_url, '" alt="', $t_attachment['alt'], '" /><br />';
Пример #4
0
# Tagging
if ($t_show_tags) {
    echo '<tr class="print">';
    echo '<th class="print-category">', lang_get('tags'), '</th>';
    echo '<td class="print" colspan="5">';
    tag_display_attached($f_bug_id);
    echo '</td></tr>';
}
echo '<tr class="print">';
echo '<td class="print-category">' . lang_get('bug_relationships') . '</td>';
echo '<td class="print" colspan="5">' . relationship_get_summary_html_preview($f_bug_id) . '</td></tr>';
if ($t_show_attachments) {
    echo '<tr class="print">';
    echo '<th class="print-category">', lang_get('attached_files'), '</th>';
    echo '<td class="print" colspan="5">';
    $t_attachments = file_get_visible_attachments($f_bug_id);
    $t_first_attachment = true;
    $t_path = config_get_global('path');
    foreach ($t_attachments as $t_attachment) {
        if ($t_first_attachment) {
            $t_first_attachment = false;
        } else {
            echo '<br />';
        }
        $c_filename = string_display_line($t_attachment['display_name']);
        $c_download_url = $t_path . htmlspecialchars($t_attachment['download_url']);
        $c_filesize = number_format($t_attachment['size']);
        $c_date_added = date(config_get('normal_date_format'), $t_attachment['date_added']);
        if (isset($t_attachment['icon'])) {
            echo '<img src="', $t_attachment['icon']['url'], '" alt="', $t_attachment['icon']['alt'], '" />&#160;';
        }
/**
 * @param PDF $pdf
 * @param $bug_ids
 * @param $version_date
 * @param $chapter_prefix
 * @param $option_show_duration
 * @param $detail_flag
 */
function process_content(PDF $pdf, $bug_ids, $version_date, $chapter_prefix, $option_show_duration, $detail_flag)
{
    $specmanagement_editor_api = new specmanagement_editor_api();
    $bug_counter = 10;
    foreach ($bug_ids as $bug_id) {
        if (bug_exists($bug_id)) {
            $bug_data = $specmanagement_editor_api->calculate_bug_data($bug_id, $version_date);
            if ($detail_flag) {
                $pdf->SetFont('Arial', 'B', 12);
                $pdf->Cell(95, 10, $chapter_prefix . '.' . $bug_counter . ' ' . utf8_decode(string_display($bug_data[1]) . ' (' . bug_format_id($bug_data[0])) . ')');
                $pdf->SetFont('Arial', '', 12);
                if ($option_show_duration == '1' && !($bug_data[7] == 0 || is_null($bug_data[7]))) {
                    $pdf->SetFont('Arial', 'B', 12);
                    $pdf->Cell(95, 10, plugin_lang_get('editor_bug_duration') . ': ' . $bug_data[7] . ' ' . plugin_lang_get('editor_duration_unit'), '', 0, 0);
                    $pdf->SetFont('Arial', '', 12);
                }
                $pdf->Ln();
                $pdf->MultiCell(0, 10, utf8_decode(trim($bug_data[2])), 0, 1);
                $pdf->MultiCell(0, 10, utf8_decode(trim($bug_data[3])), 0, 1);
                $pdf->MultiCell(0, 10, utf8_decode(trim($bug_data[4])), 0, 1);
                if (!empty($bug_data[5])) {
                    $bug_attachements = file_get_visible_attachments($bug_id);
                    $bug_attachements_count = count($bug_attachements);
                    $pdf->MultiCell(0, 10, utf8_decode(plugin_lang_get('editor_bug_attachments')) . ' (' . $bug_attachements_count . ')', 0, 1);
                    foreach ($bug_attachements as $bug_attachement) {
                        //                  var_dump( $bug_attachement );
                        /** TODO: Bilder anzeigen */
                        if ($bug_attachement['type'] == 'image') {
                            $file_download_url = config_get_global('path') . $bug_attachement['download_url'];
                            //                  $file_download_url = 'https://upload.wikimedia.org/wikipedia/commons/c/c6/Bayerischer_Wald_-_Aufichtenwald_001.jpg';
                            fopen($file_download_url, 'r');
                            $contents = file_get_contents($file_download_url);
                            $savename = '_' . $bug_attachement['id'] . $bug_attachement['display_name'];
                            $savefile = fopen($savename, 'w');
                            fwrite($savefile, $contents);
                            fclose($savefile);
                            //                     $pdf->Image( $savename );
                        }
                    }
                }
                if (!is_null($bug_data[6]) && $bug_data[6] != 0) {
                    $pdf->MultiCell(0, 10, utf8_decode(plugin_lang_get('editor_bug_notes_note')) . ' (' . $bug_data[6] . ')', 0, 1);
                }
            } else {
                $pdf->Cell(95, 10, $chapter_prefix . '.' . $bug_counter . ' ' . utf8_decode(string_display($bug_data[1]) . ' (' . bug_format_id($bug_data[0])) . ')', 0, 0);
                $pdf->Cell(95, 10, $pdf->PageNo(), 0, 1, 'R');
            }
            $bug_counter += 10;
        }
    }
}