Olá,
Sou iniciante em PHP e gostaria de uma simples ajuda numa modificação q quero fazer no meu fórum em SMF.
Quando se anexa qualquer imagem, no tópico aparece o ícone de um clips q não está cadastrado com os demais ícones no Admin Painel, ou seja, esse ícone é programado para aparecer sempre q alguma imagem é anexada. O q eu quero fazer é tirar a imagem desse clips e programar para aparecer a primeira imagem anexada no tópico e colocar limites de tamanho para essa imagem. Assim, independente da imagem q a pessoa anexar, ela apareça sempre num tamanho padrão de fora do tópico para todos verem.
Se alguém se propor a me ajudar com isso, posso postar os códigos aqui.
Ajuda Com Fórum
Started By darkgirl, 25/05/2009, 17:10
2 replies to this topic
#1
Posted 25/05/2009, 17:10
#2
Posted 25/05/2009, 19:42
Opa, podemos dar uma analisada e ver o que é possível fazer. Se é um mod no sistema, devemos ter cuidado, pois esses sistemas de foruns já utilizam de alguns mods pra auxiliar no desenvolvimento.
Mas pode postar os codigos pra analisarmos com certeza.
/*DS*/
Mas pode postar os codigos pra analisarmos com certeza.
/*DS*/
#3
Posted 27/05/2009, 17:13
Obrigada por se propor a me ajudar \o/
Acredito q não seja um mod do fórum e sim algo q já vem com o próprio SMF, por isso achei mais fácil fazer essa alteração do q tentar criar um mod q faça isso q eu quero. Eu uso o Php Expert Editor, dae fiz uma busca pela palavra "clip.gif" e taí os códigos onde essa imagem aparece.
/forum/SSI.php
/forum/Themes/Display.template.php
Acredito q não seja um mod do fórum e sim algo q já vem com o próprio SMF, por isso achei mais fácil fazer essa alteração do q tentar criar um mod q faça isso q eu quero. Eu uso o Php Expert Editor, dae fiz uma busca pela palavra "clip.gif" e taí os códigos onde essa imagem aparece.
/forum/SSI.php
// We want to show the recent attachments outside of the forum.
function ssi_recentAttachments($num_attachments = 10, $attachment_ext = array(), $output_method = 'echo')
{
global $smcFunc, $context, $modSettings, $scripturl, $txt, $settings;
// We want to make sure that we only get attachments for boards that we can see *if* any.
$attachments_boards = boardsAllowedTo('view_attachments');
// No boards? Adios amigo.
if (empty($attachments_boards))
return array();
// Is it an array?
if (!is_array($attachment_ext))
$attachment_ext = array($attachment_ext);
// Lets build the query.
$request = $smcFunc['db_query']('', '
SELECT
att.id_attach, att.id_msg, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.id_member,
IFNULL(mem.real_name, m.poster_name) AS poster_name, m.id_topic, m.subject, t.id_board, m.poster_time,
att.width, att.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ', IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
FROM {db_prefix}attachments AS att
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = att.id_msg)
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = att.id_thumb)') . '
WHERE att.attachment_type = 0' . ($attachments_boards === array(0) ? '' : '
AND m.id_board IN ({array_int:boards_can_see})') . (!empty($attachment_ext) ? '
AND att.fileext IN ({array_string:attachment_ext})' : '') . '
ORDER BY att.id_attach DESC
LIMIT {int:num_attachments}',
array(
'boards_can_see' => $attachments_boards,
'attachment_ext' => $attachment_ext,
'num_attachments' => $num_attachments,
)
);
// We have something.
$attachments = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$filename = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename']));
// Is it an image?
$attachments[$row['id_attach']] = array(
'member' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>',
),
'file' => array(
'filename' => $filename,
'filesize' => round($row['filesize'] /1024, 2) . $txt['kilobyte'],
'downloads' => $row['downloads'],
'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'],
'link' => '<img src="' . $settings['images_url'] . '/icons/clip.gif" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $filename . '</a>',
'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages']),
),
'topic' => array(
'id' => $row['id_topic'],
'subject' => $row['subject'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>',
'time' => timeformat($row['poster_time']),
),
);
// Images.
if ($attachments[$row['id_attach']]['file']['is_image'])
{
$id_thumb = empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'];
$attachments[$row['id_attach']]['file']['image'] = array(
'id' => $id_thumb,
'width' => $row['width'],
'height' => $row['height'],
'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image" alt="' . $filename . '" />',
'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />',
'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image',
'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" /></a>',
);
}
}
$smcFunc['db_free_result']($request);
// So you just want an array? Here you can have it.
if ($output_method == 'array' || empty($attachments))
return $attachments;
// Give them the default.
echo '
<table class="ssi_table" cellpadding="2">
<tr>
<th align="left">', $txt['file'], '</th>
<th align="left">', $txt['posted_by'], '</th>
<th align="left">', $txt['downloads'], '</th>
<th align="left">', $txt['filesize'], '</th>
</tr>';
foreach ($attachments as $attach)
echo '
<tr>
<td>', $attach['file']['link'], '</td>
<td>', $attach['member']['link'], '</td>
<td align="center">', $attach['file']['downloads'], '</td>
<td>', $attach['file']['filesize'], '</td>
</tr>';
echo '
</table>';
}
?>/forum/Themes/Display.template.php
// Now for the attachments, signature, ip logged, etc...
echo '
<div id="msg_', $message['id'], '_footer" class="attachments smalltext">';
// Assuming there are attachments...
if (!empty($message['attachment']))
{
echo '
<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', '; width: 100%;">';
$last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
// Show a special box for unapproved attachments...
if ($attachment['is_approved'] != $last_approved_state)
{
$last_approved_state = 0;
echo '
<fieldset>
<legend>', $txt['attach_awaiting_approve'], ' [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]</legend>';
}
if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" /></a><br />';
else
echo '
<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" /><br />';
}
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" /> ' . $attachment['name'] . '</a> ';
if (!$attachment['is_approved'])
echo '
[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
echo '
(', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}
// If we had unapproved attachments clean up.
if ($last_approved_state == 0)
echo '
</fieldset>';
echo '
</div>';
}
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)










