Ti passo quello che ho fatto io per aggiungere un campo alla tabella "attachments".
Inserire campo "attach_comment_title" in Attachments
Questa procedura consente di aggiungere un campo 'attach_comment_title' nella tabella attachments.
Lo scopo è quello di utilizzare il nuovo campo per inserire un titolo all'allegato, lasciando inalterato il campo attuale "attach_comment' che prevede un commento.
La procedura prevede:
1) la creazione del campo nella tabella
2) La modifica dei file php interessati all'inserimento di un allegato che sono:
- includes/functions_posting.php
- includes/functions_content.php
- includes/message_parser.php
- includes/acp/acp_users.php
- includes/ucp/ucp_attachments.php
- posting.php
3) La modifica del template, con l'inserimento del nuovo valore. I file da modificare sono:
- styles/prosilver/template/attachments.html
- styles/prosilver/template/posting_editor.html
- styles/prosilver/template/posting_attach_body.html
1) Creazione del campo nella tabella del Database
Da phpmyadim, aprire la tabella afphpbb3_attachments, selezionare il pulsante SQL e lanciare il seguente script che provvede a inserire nella tabella il nuovo campo.:
Codice: Seleziona tutto
ALTER TABLE `phpbb_attachments` add `attach_comment_title` VARCHAR(255) collate utf8_bin NOT NULL default '';
2 - a) Modifica file includes/functions_posting.php
Trova (riga 813):
Codice: Seleziona tutto
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
Aggiungi dopo:
Codice: Seleziona tutto
'FILE_COMMENT_TITLE' => (isset($filename_data['filecomment_title'])) ? $filename_data['filecomment_title'] : '',
Trova (riga 837):
Aggiungi dopo:
Codice: Seleziona tutto
'FILE_COMMENT_TITLE' => $attach_row['attach_comment_title'],
Trova (riga 2182):
Codice: Seleziona tutto
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "'
WHERE attach_id = " . (int) $attach_row['attach_id'] . '
AND is_orphan = 0';
Sostituire con:
Codice: Seleziona tutto
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "', attach_comment_title = '" . $db->sql_escape($attach_row['attach_comment_title']) . "'
WHERE attach_id = " . (int) $attach_row['attach_id'] . '
AND is_orphan = 0';
Trova (riga 2204):
Aggiungi dopo:
Codice: Seleziona tutto
'attach_comment_title' => $attach_row['attach_comment_title'],
2 - b) Modifica file includes/functions_content.php
Trova (riga 814):
Codice: Seleziona tutto
$row['attach_comment'] = $attachments[$attach_ids[$row['attach_id']]]['attach_comment'];
Aggiungi dopo:
Codice: Seleziona tutto
$row['attach_comment_title'] = $attachments[$attach_ids[$row['attach_id']]]['attach_comment_title'];
Trova (riga 879):
Aggiungi dopo:
2 - c) Modifica file includes/message_parser.php
Trova (riga 1372);
Codice: Seleziona tutto
$this->filename_data['filecomment'] = utf8_normalize_nfc(request_var('filecomment', '', true));
Aggiungi dopo:
Codice: Seleziona tutto
$this->filename_data['filecomment_title'] = utf8_normalize_nfc(request_var('filecomment_title', '', true));
Trova la parte di codice (riga 1379):
Codice: Seleziona tutto
// First of all adjust comments if changed
$actual_comment_list = utf8_normalize_nfc(request_var('comment_list', array(''), true));
foreach ($actual_comment_list as $comment_key => $comment)
{
if (!isset($this->attachment_data[$comment_key]))
{
continue;
}
if ($this->attachment_data[$comment_key]['attach_comment'] != $actual_comment_list[$comment_key])
{
$this->attachment_data[$comment_key]['attach_comment'] = $actual_comment_list[$comment_key];
}
}
Aggiungi il seguente blocco di codice:
Codice: Seleziona tutto
// Mod Add Comment Title
$actual_comment_list_title = utf8_normalize_nfc(request_var('comment_list_title', array(''), true));
foreach ($actual_comment_list_title as $comment_key_title => $comment)
{
if (!isset($this->attachment_data[$comment_key_title]))
{
continue;
}
if ($this->attachment_data[$comment_key_title]['attach_comment_title'] != $actual_comment_list_title[$comment_key_title])
{
$this->attachment_data[$comment_key_title]['attach_comment_title'] = $actual_comment_list_title[$comment_key_title];
}
}
// Fine Mod Add Comment Title
Trova (riga 1427);
Codice: Seleziona tutto
'attach_comment' => $this->filename_data['filecomment'],
Aggiungi dopo:
Codice: Seleziona tutto
'attach_comment_title' => $this->filename_data['filecomment_title'],
Trova (riga 1446):
Codice: Seleziona tutto
'attach_comment'=> $this->filename_data['filecomment']
Aggiungi dopo:
Codice: Seleziona tutto
'attach_comment_title'=> $this->filename_data['filecomment_title'],
Trova (riga 1453):
Aggiungi dopo;
Trova (riga 1532):
Codice: Seleziona tutto
'attach_comment' => $this->filename_data['filecomment'],
Aggiungi dopo:
Codice: Seleziona tutto
'attach_comment_title' => $this->filename_data['filecomment_title'],
Trova (riga 1551):
Codice: Seleziona tutto
'attach_comment'=> $this->filename_data['filecomment'],
Aggiungi dopo:
Codice: Seleziona tutto
'attach_comment_title' => $this->filename_data['filecomment_title'],
Trova (riga 1557):
Aggiungi dopo:
Trova (riga 1581):
Codice: Seleziona tutto
$this->filename_data['filecomment'] = utf8_normalize_nfc(request_var('filecomment', '', true));
Aggiungi dopo:
Codice: Seleziona tutto
$this->filename_data['filecomment_title'] = utf8_normalize_nfc(request_var('filecomment_title', '', true));
Trova (riga 1611):
Codice: Seleziona tutto
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
Sostituisci con:
Codice: Seleziona tutto
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, attach_comment_title
Trova (riga 1621):
Codice: Seleziona tutto
set_var($this->attachment_data[$pos]['attach_comment'], $_POST['attachment_data'][$pos]['attach_comment'], 'string', true);
Aggiungi dopo:
Codice: Seleziona tutto
set_var($this->attachment_data[$pos]['attach_comment_title'], $_POST['attachment_data'][$pos]['attach_comment_title'], 'string', true);
Trova (riga 1636):
Codice: Seleziona tutto
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
Sostituisci con:
Codice: Seleziona tutto
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, attach_comment_title
Trova (riga 1647):
Codice: Seleziona tutto
set_var($this->attachment_data[$pos]['attach_comment'], $_POST['attachment_data'][$pos]['attach_comment'], 'string', true);
Aggiungi dopo:
Codice: Seleziona tutto
set_var($this->attachment_data[$pos]['attach_comment_title'], $_POST['attachment_data'][$pos]['attach_comment_title'], 'string', true);
2 - d) Modifica file includes/acp/acp_users.php
Trova (riga 2025):
Aggiungi dopo:
Codice: Seleziona tutto
'COMMENT_TITLE' => nl2br($row['attach_comment_title']),
2 - e) Modifica file includes/ucp/ucp_attachments.php
Trova (riga 151):
Aggiungi:
Codice: Seleziona tutto
'COMMENT_TITLE' => bbcode_nl2br($row['attach_comment_title']),
2 - f) Modifica file posting.php
Trova (riga 419):
Codice: Seleziona tutto
$sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename
Sostituire con:
Codice: Seleziona tutto
$sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, attach_comment_title
3) Modifica file styles/prosilver/template/attachments.html
Trova
Aggiungi dopo:
Codice: Seleziona tutto
<!-- IF _file.COMMENT_TITLE --><dd>{_file.COMMENT_TITLE}</dd><!-- ENDIF -->
3) Modifica file styles/prosilver/template/posting_editor.html
Trova
Aggiungi dopo:
Codice: Seleziona tutto
<dl>
<dt><label for="filecomment">Nome della specie:</label></dt>
<dd><textarea name="comment_list_title[{attach_row.ASSOC_INDEX}]" id="comment_list_title_{attach_row.ASSOC_INDEX}" rows="1" cols="35" class="inputbox">{attach_row.FILE_COMMENT_TITLE}</textarea></dd>
</dl>
3) Modifica file styles/prosilver/template/posting_attach_body.html
Trova:
Codice: Seleziona tutto
<dl>
<dt><label for="filecomment">{L_FILE_COMMENT}:</label></dt>
<dd><textarea name="filecomment" id="filecomment" rows="1" cols="60" class="inputbox autowidth">{FILE_COMMENT}</textarea></dd>
</dl>
Inserisci prima:
Codice: Seleziona tutto
<dl>
<dt><label for="filecomment_title">Nome della specie:</label></dt>
<dd><textarea name="filecomment_title" id="filecomment_title" rows="1" cols="60" class="inputbox autowidth">(FILE_COMMENT_TITLE)</textarea></dd>
</dl>