getContentDisposition() public method

This will return either NULL or the string "attachment".
public getContentDisposition ( ) : mixed
return mixed
コード例 #1
0
ファイル: attachment.php プロジェクト: nidzix/Newscoop
$filename = urldecode(basename($attachment));
$extension = '';
if (($extensionStart = strrpos($attachment, '.')) !== false) {
    $extension = strtolower(substr($attachment, $extensionStart + 1));
    $attachment = substr($attachment, 0, $extensionStart);
}
$attachmentId = (int) ltrim($attachment, " 0\t\n\r");
$attachmentObj = new Attachment($attachmentId);
if (!$attachmentObj->exists()) {
    header('HTTP/1.0 404 Not Found');
    echo 'Error 404: File not found';
    exit;
}
header('Content-Type: ' . $attachmentObj->getMimeType());
if ($g_download == 1) {
    header('Content-Disposition: ' . $attachmentObj->getContentDisposition() . '; filename="' . $attachmentObj->getFileName()) . '"';
} else {
    if ($g_show_in_browser == 1) {
        header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()) . '"';
    } else {
        if (!$attachmentObj->getContentDisposition() && strstr($attachmentObj->getMimeType(), 'image/') && (strstr($_SERVER['HTTP_ACCEPT'], $attachmentObj->getMimeType()) || strstr($_SERVER['HTTP_ACCEPT'], '*/*'))) {
            header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()) . '"';
        } else {
            header('Content-Disposition: ' . $attachmentObj->getContentDisposition() . '; filename="' . $attachmentObj->getFileName()) . '"';
        }
    }
}
header('Content-Length: ' . $attachmentObj->getSizeInBytes());
$filePath = $attachmentObj->getStorageLocation();
if (file_exists($filePath)) {
    readfile($filePath);
コード例 #2
0
ファイル: edit.php プロジェクト: sourcefabric/newscoop
?>
><?php 
echo $translator->trans("All translations", array(), 'article_files');
?>
    </TD>
</TR>
<TR>
    <TD ALIGN="left" colspan="2"  style="padding-left: 15px;"><?php 
echo $translator->trans("Do you want this file to open in the user's browser, or to automatically download?", array(), 'article_files');
?>
</TD>
</TR>
<TR>
    <TD colspan="2" style="padding-left: 30px;">
    <INPUT type="radio" name="f_content_disposition" value="" <?php 
if (!$attachmentObj->getContentDisposition()) {
    ?>
 checked<?php 
}
?>
 <?php 
p($isDisabled);
?>
><?php 
echo $translator->trans("Open in the browser", array(), 'article_files');
?>
<br>
    <INPUT type="radio" name="f_content_disposition" value="attachment" <?php 
if ($attachmentObj->getContentDisposition()) {
    ?>
 checked<?php 
コード例 #3
0
ファイル: edit.php プロジェクト: nistormihai/Newscoop
</TR>
<TR>
	<TD ALIGN="left" colspan="2" style="padding-left: 15px;"><?php  putGS("Should this file only be available for this translation of the article, or for all translations?"); ?></TD>
</TR>
<TR>
	<TD colspan="2" class="indent"  style="padding-left: 30px;">
	<INPUT type="radio" name="f_language_specific" value="yes" <?php if ($attachmentObj->getLanguageId()) { ?> checked<?php } ?> <?php p($isDisabled); ?>><?php putGS("Only this translation"); ?><br>
	<INPUT type="radio" name="f_language_specific" value="no" <?php if (!$attachmentObj->getLanguageId()) { ?> checked<?php } ?>  <?php p($isDisabled); ?>><?php putGS("All translations"); ?>
	</TD>
</TR>
<TR>
	<TD ALIGN="left" colspan="2"  style="padding-left: 15px;"><?php  putGS("Do you want this file to open in the user's browser, or to automatically download?"); ?></TD>
</TR>
<TR>
	<TD colspan="2" style="padding-left: 30px;">
	<INPUT type="radio" name="f_content_disposition" value="" <?php if (!$attachmentObj->getContentDisposition()) { ?> checked<?php } ?> <?php p($isDisabled); ?>><?php putGS("Open in the browser"); ?><br>
	<INPUT type="radio" name="f_content_disposition" value="attachment" <?php if ($attachmentObj->getContentDisposition()) { ?> checked<?php } ?> <?php p($isDisabled); ?>><?php putGS("Automatically download"); ?>
	</TD>
</TR>
<?php if ($g_user->hasPermission('ChangeFile')) { ?>
<TR>
	<TD COLSPAN="2">
	<DIV ALIGN="CENTER">
    <INPUT TYPE="HIDDEN" NAME="f_publication_id" VALUE="<?php  p($f_publication_id); ?>">
    <INPUT TYPE="HIDDEN" NAME="f_issue_number" VALUE="<?php  p($f_issue_number); ?>">
    <INPUT TYPE="HIDDEN" NAME="f_section_number" VALUE="<?php  p($f_section_number); ?>">
    <INPUT TYPE="HIDDEN" NAME="f_article_number" VALUE="<?php  p($f_article_number); ?>">
    <INPUT TYPE="HIDDEN" NAME="f_language_id" VALUE="<?php  p($f_language_id); ?>">
    <INPUT TYPE="HIDDEN" NAME="f_language_selected" VALUE="<?php  p($f_language_selected); ?>">
    <INPUT TYPE="HIDDEN" NAME="f_attachment_id" VALUE="<?php  p($f_attachment_id); ?>">
	<INPUT TYPE="submit" NAME="Save" VALUE="<?php  putGS('Save'); ?>" class="button">
コード例 #4
0
ファイル: edit-attachment.php プロジェクト: nidzix/Newscoop
            <label for="description"><?php 
putGS("Description");
?>
:</label>
            <input id="description" type="text" name="f_description" value="<?php 
echo htmlspecialchars($object->getDescription($object->getLanguageId()));
?>
" size="50" maxlength="255" class="input_text" />
        </li>
        <li>
            <label><?php 
putGS("Do you want this file to open in the user's browser, or to automatically download?");
?>
</label>
            <input id="disposition0" class="input_radio" type="radio" name="f_content_disposition" value=""<?php 
if ($object->getContentDisposition() == NULL) {
    echo ' checked="checked"';
}
?>
 />
            <label for="disposition0" class="inline-style left-floated" style="padding-right:15px"><?php 
putGS("Open in the browser");
?>
</label>
            <input id="disposition1" class="input_radio" type="radio" name="f_content_disposition" value="attachment"<?php 
if ($object->getContentDisposition() == 'attachment') {
    echo ' checked="checked"';
}
?>
 />
            <label for="disposition1" class="inline-style left-floated"><?php 
コード例 #5
0
ファイル: attachment.php プロジェクト: nistormihai/Newscoop
if (($extensionStart = strrpos($attachment, '.')) !== false) {
    $extension = strtolower(substr($attachment, $extensionStart + 1));
    $attachment = substr($attachment, 0, $extensionStart);
}
$attachmentId = (int)ltrim($attachment, " 0\t\n\r\0");

$attachmentObj = new Attachment($attachmentId);
if (!$attachmentObj->exists()) {
    header('HTTP/1.0 404 Not Found');
    echo 'Error 404: File not found';
    exit;
}

header('Content-Type: ' . $attachmentObj->getMimeType());
if ($g_download == 1) {
    header('Content-Disposition: ' . $attachmentObj->getContentDisposition()
                    . '; filename="' . $attachmentObj->getFileName()).'"';
} else if ($g_show_in_browser == 1) {
    header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()).'"';
} else {
    if (!$attachmentObj->getContentDisposition() &&
        strstr($attachmentObj->getMimeType(), "image/") &&
        (strstr($_SERVER['HTTP_ACCEPT'], $attachmentObj->getMimeType()) ||
        (strstr($_SERVER['HTTP_ACCEPT'], "*/*")))) {
        header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()).'"';
    } else {
        header('Content-Disposition: ' . $attachmentObj->getContentDisposition()
                        . '; filename="' . $attachmentObj->getFileName()).'"';
    }
}
header('Content-Length: ' . $attachmentObj->getSizeInBytes());
コード例 #6
0
    <?php echo SecurityToken::FormParameter(); ?>
    <input type="hidden" name="f_attachment_id" value="<?php echo $object->getAttachmentId(); ?>" />

<div class="ui-widget-content big-block block-shadow padded-strong">
    <fieldset class="plain">

    <legend><?php putGS('Change attachment information'); ?></legend>

    <ul>
        <li>
            <label for="description"><?php putGS("Description"); ?>:</label>
            <input id="description" type="text" name="f_description" value="<?php echo htmlspecialchars($object->getDescription($object->getLanguageId())); ?>" size="50" maxlength="255" class="input_text" />
        </li>
        <li>
            <label><?php putGS("Do you want this file to open in the user's browser, or to automatically download?"); ?></label>
            <input id="disposition0" class="input_radio" type="radio" name="f_content_disposition" value=""<?php if ($object->getContentDisposition() == NULL) { echo ' checked="checked"'; } ?> />
            <label for="disposition0" class="inline-style left-floated" style="padding-right:15px"><?php putGS("Open in the browser"); ?></label>
            <input id="disposition1" class="input_radio" type="radio" name="f_content_disposition" value="attachment"<?php if ($object->getContentDisposition() == 'attachment') { echo ' checked="checked"'; } ?> />
            <label for="disposition1" class="inline-style left-floated"><?php putGS("Automatically download"); ?></label>
        </li>
        <li>
            <label>&nbsp;</label>
            <input type="submit" name="Save" value="<?php  putGS('Save'); ?>" class="button" />
        </li>
    </ul>

    </fieldset>
</div>

</form>