AddFileToArticle() public static method

Link the given file with the given article.
public static AddFileToArticle ( integer $p_attachmentId, integer $p_articleNumber ) : void
$p_attachmentId integer
$p_articleNumber integer
return void
示例#1
0
window.opener.location.reload();
</script>
<?php
	exit;
}

$f_language_selected = Input::Get('f_language_selected', 'int', 0);
$f_article_number = Input::Get('f_article_number', 'int', 0);
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
	camp_html_display_error(getGS("Article does not exist."), null, true);
	exit;
}

foreach ((array) $_POST['item'] as $attachmentId) {
    ArticleAttachment::AddFileToArticle((int) $attachmentId, $articleObj->getArticleNumber());
}
$logtext = getGS('$1 file/s attached to article', sizeof($_POST['item']));
Log::ArticleMessage($articleObj, $logtext, null, 38, TRUE);

?>
<script type="text/javascript">
try {
    parent.$.fancybox.reload = true;
    parent.$.fancybox.message = '<?php putGS('Files attached.'); ?>';
    parent.$.fancybox.close();
} catch (e) {}
</script>

<?php exit; ?>
示例#2
0
}

if (!empty($_FILES['f_file'])) {
	$file = Attachment::OnFileUpload($_FILES['f_file'], $attributes);
} else {
	camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'files/popup.php'));
}

// Check if image was added successfully
if (PEAR::isError($file)) {
    setMessage($file->getMessage());
	camp_html_goto_page($BackLink);
}

if (!$inArchive) {
    ArticleAttachment::AddFileToArticle($file->getAttachmentId(), $articleObj->getArticleNumber());

    $logtext = getGS('File #$1 "$2" attached to article',
        $file->getAttachmentId(), $file->getFileName());
    Log::ArticleMessage($articleObj, $logtext, null, 38, TRUE);

    setMessage(getGS('File attached.'));
} else { ?>
<script type="text/javascript"><!--
    if (opener && !opener.closed && opener.onUpload) {
        opener.onUpload();
        opener.focus();
        window.close();
    }
//--></script>
<?php } ?>