News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Modificare la funzione unread ....

Started by Tanakino, February 28, 2012, 11:05:13 AM

Previous topic - Next topic

Tanakino

Salve,

utilizzo SMF 1.1.16 e vorrei modificare la funzione "unread" affinchè svolgesse lo stesso identico compito di "recenttopics".

Così mi sono detto : basta fare un copia-incolla delle linee della seconda nella prima nel file sources/recent.php

Invece no .. non funziona ..

Come mai ????


Grazie
T.

emanuele

???
Perché semplicemente non cambi il link dove la funzione "si palesa"?

Non ricordo le funzioni in particolare, quindi non dico niente sul copia e incolla.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Tanakino

#2
Ciao Emanuele e grazie,

è solo che non vorrei che l' utente si sentisse come se mancasse qualcosa .. la funzione unread è utilissima ..


scusami ancora, ma ho sbagliato a spiegare ...

La funzione unread è in Recent.template.php

function template_unread()
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

echo '
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>', theme_linktree(), '</td>
</tr>
</table>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="middletext" valign="middle">' . $txt[139] . ': ' . $context['page_index'] . '</td>';

if ($settings['show_mark_read'])
{
// Generate the button strip.
$mark_read = array(
'markread' => array('text' => !empty($context['no_board_limits']) ? 452 : 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';sesc=' . $context['session_id']),
);

echo '
<td align="right" style="padding-right: 1ex;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
', template_button_strip($mark_read, 'bottom'), '
</tr>
</table>
</td>';
}
echo '
</tr>
</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="bordercolor">
<tr><td>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="titlebg">';
if (!empty($context['topics']))
echo '
<td width="10%" colspan="2">&nbsp;</td>
<td>
<a href="', $scripturl, '?action=', isset($_REQUEST['action']) ? $_REQUEST['action'] : 'unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], isset($context['querystring_day_limits']) ? $context['querystring_day_limits'] : '', ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="14%">
<a href="', $scripturl, '?action=', isset($_REQUEST['action']) ? $_REQUEST['action'] : 'unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], isset($context['querystring_day_limits']) ? $context['querystring_day_limits'] : '', ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="4%" align="center">
<a href="', $scripturl, '?action=', isset($_REQUEST['action']) ? $_REQUEST['action'] : 'unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], isset($context['querystring_day_limits']) ? $context['querystring_day_limits'] : '', ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="4%" align="center">
<a href="', $scripturl, '?action=', isset($_REQUEST['action']) ? $_REQUEST['action'] : 'unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], isset($context['querystring_day_limits']) ? $context['querystring_day_limits'] : '', ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="24%">
<a href="', $scripturl, '?action=', isset($_REQUEST['action']) ? $_REQUEST['action'] : 'unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], isset($context['querystring_day_limits']) ? $context['querystring_day_limits'] : '', ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td>';
else
echo '
<td width="100%" colspan="7">', $context['showing_all_topics'] ? $txt[151] : $txt['unread_topics_visit_none'], '</td>';
echo '
</tr>';

foreach ($context['topics'] as $topic)
{
if (!isset($topic['is_read'])) $topic['is_read'] = 0;
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'], $topic['is_read'] == 0 ? ' <a href="'. $topic['new_href']. '"><img src="'. $settings['images_url']. '/'. $context['user']['language']. '/new.gif" alt="'. $txt[302]. '" /></a>' : '', '<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

if (!empty($context['topics']) && !$context['showing_all_topics'])
echo '
<tr class="titlebg">
<td colspan="7" align="right" class="middletext"><a href="', $scripturl, '?action=unread;all', $context['querystring_board_limits'], '">', $txt['unread_topics_all'], '</a></td>
</tr>';

echo '
</table>
</td></tr>
</table>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="middletext" valign="middle">', $txt[139], ': ', $context['page_index'], '</td>';

if ($settings['show_mark_read'])
echo '
<td align="right" style="padding-right: 1ex;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
', template_button_strip($mark_read, 'top'), '
</tr>
</table>
</td>';
echo '
</tr>
</table><br />
<div class="tborder"><div class="titlebg2">
<table cellpadding="8" cellspacing="0" width="55%">
<tr>
<td align="left" style="padding-top: 2ex;" class="smalltext">', !empty($modSettings['enableParticipation']) ? '
<img src="' . $settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' . $txt['participation_caption'] . '<br />' : '', '
<img src="' . $settings['images_url'] . '/topic/normal_post.gif" alt="" align="middle" /> ' . $txt[457] . '<br />
<img src="' . $settings['images_url'] . '/topic/hot_post.gif" alt="" align="middle" /> ' . $txt[454] . '<br />
<img src="' . $settings['images_url'] . '/topic/veryhot_post.gif" alt="" align="middle" /> ' . $txt[455] . '
</td>
<td align="left" valign="top" style="padding-top: 2ex;" class="smalltext">
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" alt="" align="middle" /> ' . $txt[456] . '<br />' . ($modSettings['enableStickyTopics'] == '1' ? '
<img src="' . $settings['images_url'] . '/icons/' . (!empty($settings['seperate_sticky_lock']) ? 'quick_sticky' : 'normal_post_sticky') . '.gif" alt="" align="middle" /> ' . $txt['smf96'] . '<br />' : '') . ($modSettings['pollMode'] == '1' ? '
<img src="' . $settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' . $txt['smf43'] : '') . '
</td>
</tr>
</table>
</div></div>';
}



l'altra è nel file Recent.php

// get xx recent topics (read or unread) from ssi_recentTopics and call the unread template to display them nicely
function RecentTopics() {
global $context, $settings, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $scripturl;
require_once('SSI.php');
if (!isset($_REQUEST['action'])) $_REQUEST['action'] == 'recenttopics';

if (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$board_limits = '';
if (isset($_REQUEST['boards']) && is_numeric(str_replace(',','', $_REQUEST['boards']))) {
$include_boards = explode(',', $_REQUEST['boards']);
$board_limits = ';boards='.$_REQUEST['boards'];
}
elseif (isset($_REQUEST['boards']) && $_REQUEST['boards'] == 'all') {
$include_boards = null;
$board_limits = ';boards='.$_REQUEST['boards'];
}
else
$include_boards = $context['user']['recentPosts']['boards'];

if (isset($_REQUEST['limit']) && is_numeric($_REQUEST['limit'])) {
if (isset($modSettings['recentpostsLimitdays']) && $modSettings['recentpostsLimitdays'] != 0)
if ($_REQUEST['limit'] > $modSettings['recentpostsLimitdays']) {
$limit_days = $modSettings['recentpostsLimitdays'];
}
else { $limit_days = $_REQUEST['limit'];}
}
elseif (isset($modSettings['recentpostsLimitdays']) && $modSettings['recentpostsLimitdays'] != 0)
$limit_days = $modSettings['recentpostsLimitdays'];

$request = db_query("
SELECT count(*)
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_LAST_MSG >= " . (isset($limit_days) ? '0' : ($modSettings['maxMsgID'] - 35 * min($modSettings['defaultMaxTopics'], 5))) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . (!empty($include_boards) ? "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")"  : '') . (isset($limit_days) ? "
AND m.posterTime > " . (time() - ($limit_days*24*60*60)) : '') . (!empty($member_id) ? "
AND m.ID_MEMBER = {$member_id}" : '') . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
", __FILE__, __LINE__);
list($num_topics) = mysql_fetch_row($request);
mysql_free_result($request);

$sort_methods = array(
'subject' => 'ms.subject',
'starter' => 'IFNULL(mem.realName, ms.posterName)',
'replies' => 't.numReplies',
'views' => 't.numViews',
'first_post' => 't.ID_TOPIC',
'last_post' => 't.ID_LAST_MSG'
);
// The default is the most logical: newest first.
if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
{
$sort_by = 'last_post';
$_REQUEST['sort'] = 't.ID_LAST_MSG';
$ascending = isset($_REQUEST['asc']);

$context['querystring_sort_limits'] = $ascending ? ';asc' : '';
}
// But, for other methods the default sort is ascending.
else
{
$sort_by = $_REQUEST['sort'];
$_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']];
$ascending = !isset($_REQUEST['desc']);

$context['querystring_sort_limits'] = ';sort=' . $sort_by . ($ascending ? '' : ';desc');
}
$context['sort_direction'] = $ascending ? 'up' : 'down';

$context['linktree'][] = array(
'url' => $scripturl . '?action=' . $_REQUEST['action'] . $context['querystring_sort_limits'],
'name' => $txt['recent_topics']
);
// Make sure the starting place makes sense and construct the page index.
if (!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
$context['querystring_board_limits'] = ';start=%d';

if (isset($limit_days))
$context['querystring_day_limits'] = ";limit={$limit_days}";
else $context['querystring_day_limits'] = '';

$context['page_index'] = constructPageIndex($scripturl . '?action=' . $_REQUEST['action'] . $board_limits . $context['querystring_sort_limits'] . $context['querystring_board_limits'] . $context['querystring_day_limits'], $_REQUEST['start'], $num_topics, $modSettings['defaultMaxTopics'], true);
$context['current_page'] = (int) $_REQUEST['start'] / $modSettings['defaultMaxTopics'];

$context['links'] = array(
'first' => $_REQUEST['start'] >= $modSettings['defaultMaxTopics'] ? $scripturl . '?action=' . $_REQUEST['action'] . sprintf($context['querystring_board_limits'], 0) . $context['querystring_day_limits'] . $context['querystring_sort_limits'] : '',
'prev' => $_REQUEST['start'] >= $modSettings['defaultMaxTopics'] ? $scripturl . '?action=' . $_REQUEST['action'] . sprintf($context['querystring_board_limits'], $_REQUEST['start'] - $modSettings['defaultMaxTopics']) . $context['querystring_day_limits'] . $context['querystring_sort_limits'] : '',
'next' => $_REQUEST['start'] + $modSettings['defaultMaxTopics'] < $num_topics ? $scripturl . '?action=' . $_REQUEST['action'] . sprintf($context['querystring_board_limits'], $_REQUEST['start'] + $modSettings['defaultMaxTopics']) . $context['querystring_day_limits'] . $context['querystring_sort_limits'] : '',
'last' => $_REQUEST['start'] + $modSettings['defaultMaxTopics'] < $num_topics ? $scripturl . '?action=' . $_REQUEST['action'] . sprintf($context['querystring_board_limits'], floor(($num_topics - 1) / $modSettings['defaultMaxTopics']) * $modSettings['defaultMaxTopics']) . $context['querystring_day_limits'] . $context['querystring_sort_limits'] : '',
'up' => $scripturl,
);
$context['page_info'] = array(
'current_page' => $_REQUEST['start'] / $modSettings['defaultMaxTopics'] + 1,
'num_pages' => floor(($num_topics - 1) / $modSettings['defaultMaxTopics']) + 1
);

$context['ascending'] = $ascending;
$context['topics'] = array(); //make sure the array exists so no errors are thrown in Recent.template
ssi_recentTopics($modSettings['defaultMaxTopics'], null, 'extended', $include_boards, isset($limit_days) ? $limit_days : null);
$settings['show_mark_read'] = FALSE;
$context['showing_all_topics'] = null; //to prevent unknown index errors in Recent.template
//$context['page_index'] = 1;
$txt['unread_topics_all'] = $txt['unread_topics_only'];
$txt['unread_topics_visit_none'] = $txt['RP_topics_visit_none'];
$context['sort_by'] = $sort_by;
$context['page_title'] = $txt['recent_topics'];
$context['querystring_board_limits'] = $context['querystring_board_limits'].$board_limits.';start='.$_REQUEST['start'];
loadTemplate('Recent');
$context['sub_template'] = 'unread';
}



ammesso che abbia interpretato bene ....


T.

emanuele

mmm...beh, allora non capisco.

Vuoi che unread funzioni esattamente come recenttopics, ma vuoi anche che continui a fare il suo lavoro? ???

Allora: c'è l'action unread (e ci saranno dei link da cui è possibile accedere a tale funzionalità) e c'è l'action recenttopics (e ci saranno dei link da cui è possibile accedere a tale funzionalità).

Ora, tu cosa vuoi: che quando qualcuno clicca su link che normalmente produrrebbero unread gli appaia l'azione recenttopics?
Oppure vuoi che da qualche parte unread faccia vedere recenttopics?

Scusa, sono un po' fuso ultimamente (scrivere codice dalla mattina alla sera non è salutare per i miei due neuroni! :P), quindi passo passo, se le hai anche con qualche immagine, spiega bene quello che vuoi ottenere.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Tanakino

Grazie Emanuele, sempre gentilissimo .

Io vorrei che quando un utente clicca su " Mostra le discussioni non lette dall'ultima visita " si generasse un action recenttopics ma ... senza farlo vedere .. vorrei che nella barra del browser si vedesse comunque :

http://ilmioforum/unread/


per questo ho pensato : se io copio ed incollo una funzione nell'altra ho risolto ... poi però ho visto che la funzione recenttopics usa la grafica di unread e dunque non posso sostituire unread in toto come credevo ...

Come potrei fare ? ho visto dei forum dove ce l'hanno fatta ...


Grazie mille, sei sempre molto gentile !!

T.

Tanakino


Tanakino


emanuele

Scusa, ma qual'è il link che usi per i recent topics?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Tanakino

E' questo ...

http://mioforum.com/recenttopics


Grazie !!!

emanuele

Ok, non avevo visto che  funzione viene da SSI...

ehhh...mod_rewrite?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Tanakino

Grazie Emanuele !!!

perdona l' ignoranza ... cioè ???


T.

emanuele

Cioè cambiare htaccess e fare in modo che quando clicchi unread venga fornita la pagina readttopic...è l'unica facile che mi viene in mente, ma non chiedermi come perché io e htaccess non andiamo per niente d'accordo.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: