Fireboardのファイルとイメージのアップロードで以前から不満に思っていたのですが、アップロードに失敗などすると二度とアップロードできなくなってしまわないですか?これは、データベースに登録されてしまうとアップロード済みになってしまい、ファイルの存在の有無にかかわらずアップロードされていると判断しているからのようです。
以下のようにアップロード済みでファイルが存在するならタグを表示するようにしました。
Root/components/com_fireboard/template/default/post.php
foreach ($attachments as $att)
{
if (preg_match("&/fbfiles/files/&si", $att->filelocation)) {
$no_file_upload = "1";
}
if (preg_match("&/fbfiles/images/&si", $att->filelocation)) {
$no_image_upload = "1";
}
}
を
$upload_files = array();
$upload_images = array();
foreach ($attachments as $att)
{
if (preg_match("&/fbfiles/files/&si", $att->filelocation) && file_exists($att->filelocation)) {
$no_file_upload = "1";
$upload_files[] = '[file]'. str_replace($mosConfig_absolute_path, $mosConfig_live_site, $att->filelocation). '[/file]';
}
if (preg_match("&/fbfiles/images/&si", $att->filelocation) && file_exists($att->filelocation)) {
$no_image_upload = "1";
$upload_images[] = '[img]'. str_replace($mosConfig_absolute_path, $mosConfig_live_site, $att->filelocation). '[/img]';
}
}
に変更。そしてこのとき追加した$upload_filesと$upload_imagesを次のファイルで使います。
Root/components/com_fireboard/template/default/fb_write.html.php
if (($fbConfig['allowImageUpload'] || ($fbConfig['allowImageRegUpload'] && $my->id != 0) || $is_moderator) && ($no_upload == "0" || $no_image_upload == "0"))
{
?>
<tr class = "<?php echo $boardclass; ?>sectiontableentry1">
<td class = "fb_leftcolumn">
<strong><?php echo _IMAGE_SELECT_FILE; ?></strong>
</td>
<td>
<input type = 'file' class = 'button' name = 'attachimage' onmouseover = "helpline('iu')"/>
<input type = "button" class = "button" name = "addImagePH" value = "<?php echo _POST_ATTACH_IMAGE;?>" style = "cursor:hand; width: 40px" onclick = "javascript:emo(' [img] ');" onmouseover = "helpline('ip')"/>
</td>
</tr>
<?php
}
?>
<?php
if (($fbConfig['allowFileUpload'] || ($fbConfig['allowFileRegUpload'] && $my->id != 0) || $is_moderator) && ($no_upload == "0" || $no_file_upload == "0"))
{
?>
<tr class = "<?php echo $boardclass; ?>sectiontableentry2">
<td class = "fb_leftcolumn">
<strong><?php echo _FILE_SELECT_FILE; ?></strong>
</td>
<td>
<input type = 'file' class = 'button' name = 'attachfile' onmouseover = "helpline('fu')" style = "cursor:hand"/>
<input type = "button" class = "button" name = "addFilePH" value = "<?php echo _POST_ATTACH_FILE;?>" style = "cursor:hand; width: 40px" onclick = "javascript:emo(' [file] ');" onmouseover = "helpline('fp')"/>
</td>
</tr>
<?php
}
を
if (($fbConfig['allowImageUpload'] || ($fbConfig['allowImageRegUpload'] && $my->id != 0) || $is_moderator) && ($no_upload == "0" || $no_image_upload == "0"))
{
?>
<tr class = "<?php echo $boardclass; ?>sectiontableentry1">
<td class = "fb_leftcolumn">
<strong><?php echo _IMAGE_SELECT_FILE; ?></strong>
</td>
<td>
<input type = 'file' class = 'button' name = 'attachimage' onmouseover = "helpline('iu')"/>
<input type = "button" class = "button" name = "addImagePH" value = "<?php echo _POST_ATTACH_IMAGE;?>" style = "cursor:hand; width: 40px" onclick = "javascript:emo(' [img] ');" onmouseover = "helpline('ip')"/>
</td>
</tr>
<?php
}
if (($fbConfig['allowImageUpload'] || ($fbConfig['allowImageRegUpload'] && $my->id != 0) || $is_moderator) && count($upload_images) && $no_image_upload == "1")
{
?>
<tr class = "<?php echo $boardclass; ?>sectiontableentry1">
<td class = "fb_leftcolumn">
<strong>アップロード済みイメージ</strong>
</td>
<td>
<?php echo implode('<br />', $upload_images); ?>
</td>
</tr>
<?php
}
if (($fbConfig['allowFileUpload'] || ($fbConfig['allowFileRegUpload'] && $my->id != 0) || $is_moderator) && ($no_upload == "0" || $no_file_upload == "0"))
{
?>
<tr class = "<?php echo $boardclass; ?>sectiontableentry2">
<td class = "fb_leftcolumn">
<strong><?php echo _FILE_SELECT_FILE; ?></strong>
</td>
<td>
<input type = 'file' class = 'button' name = 'attachfile' onmouseover = "helpline('fu')" style = "cursor:hand"/>
<input type = "button" class = "button" name = "addFilePH" value = "<?php echo _POST_ATTACH_FILE;?>" style = "cursor:hand; width: 40px" onclick = "javascript:emo(' [file] ');" onmouseover = "helpline('fp')"/>
</td>
</tr>
<?php
}
if (($fbConfig['allowFileUpload'] || ($fbConfig['allowFileRegUpload'] && $my->id != 0) || $is_moderator) && count($upload_files) && $no_file_upload == "1")
{
?>
<tr class = "<?php echo $boardclass; ?>sectiontableentry2">
<td class = "fb_leftcolumn">
<strong>アップロード済みファイル</strong>
</td>
<td>
<?php echo implode('<br />', $upload_files); ?>
</td>
</tr>
<?php
}
に変更。これでアップロード済みのファイルがあって且つファイルが存在していれば、アップロードフォームに代わってコピーして使えるタグ(自分で選択してコピーしないと駄目ですけど)が表示されます。
※メッセージなどは、好みで変更されたら良いと思うし、そこまでしなくてもと思われるなら、最初の変更分で$upload_files、$upload_imagesを定義しなければfb_write.html.phpも変更しなくてOKですね。
と、こうやって変更してみるとデータベースに登録時、ファイルの存在チェックをしていないことに気がつきますね。どんどんアップデートされるでしょうから、様子を見ながらですね。
ちなみにプロフィール部分のリンクを直そうと思っていたのですが、マルチアップロードについて書かれた以下の記事を見て思いつきました。マルチアップロードできるようにするHackが書かれています。










