Pagina 1 di 1

Lista topic che contengono un certo tag con mod_topiclist

Inviato: 05/07/2010, 11:52
da Franc[e]sco
Ciao, sto facendo un forum che cataloga anime e manga e per le liste del materiale utilizzo la mod_topiclist di Bingo. Solo che parte del materiale che ho sul forum è incompleto e ho bisogno di poter avere una lista di tutto ciò che è incompleto per poterlo aggiornare più facilmente. Tutti i topic "incompleti" contengono il tag "[incorso][/incorso]". Stavo pensando, sarebbe possibile aggiungere un controllo del genere alla mod_topiclist? Come potrei fare?

Questo è il codice della mod_topiclist (con qualche modifica in modo che mostri per forza tutti i topic):

Codice: Seleziona tutto

<?php
/**
*
* @package phpBB3
* @version $Id: user_topic_list.php 2009 11 30 Bingo $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'includes/functions_display.php');

// Start session
$user->session_begin();
$auth->acl($user->data);

$user->setup('viewforum');

// Start initial var setup
$forum_id	= request_var('f', 0);     // Forum corrente
$time_cor	= 1 ; // periodo della ricerca, per default 90 gg.
$multi_forum = $_GET['f'];

if (!$forum_id)
{
	trigger_error('NO_FORUM');
}

if (strstr($multi_forum, ",")){
	// url con elenco di forum_id separati dalla virgola
	// controlla l'esistenza del Forum e dei permessi di lettura
	global $db,$auth;
	$forums_id = array();
	$sql = "SELECT forum_id, forum_type, forum_name FROM " . FORUMS_TABLE . " WHERE forum_id IN($multi_forum) || parent_id IN($multi_forum)";
	$result = $db->sql_query($sql);

	while($row = $db->sql_fetchrow($result)) {
    		if (!$auth->acl_gets('f_list', 'f_read', $row['forum_id']) === false && $row['forum_type'] == FORUM_POST) 
		{
		$forums_id[] = $row['forum_id'];
		$forums_name[] = $row['forum_name'];
    		}
	}
	$db->sql_freeresult($result);

	$where_list = '' ;
	foreach($forums_id as $forum_cor){
		if ($where_list == ''){
		$where_list = $forum_cor ;
		}else{
		$where_list = $where_list . "," . $forum_cor ;
		}
	}
	//Obtain forum name
	$forum_name = $forums_name[0];
	$template->assign_var('FORUM_ID_COR', $forums_id[0]); 
	$template->assign_var('FORUM_NAME', $forums_name[0]);   
	$template->assign_var('U_VIEWFORUM',append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forums_id[0]));

}else{
	// url con unico forum_id
	$sql = "SELECT f.*
   		FROM ".FORUMS_TABLE." f
   		WHERE f.forum_id = $forum_id";
	$result = $db->sql_query($sql);
	$forum_data = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

	if (!$forum_data)
	{
   		trigger_error('NO_FORUM');
	}

	//Obtain forum name
	$forum_name = $forum_data['forum_name'];   //
	$template->assign_var('FORUM_ID_COR', $forum_id); 
	$template->assign_var('FORUM_NAME', $forum_name);   
	$template->assign_var('U_VIEWFORUM',append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id));

	$icons = $cache->obtain_icons();

	// controlla i permessi di lettura e crea la lista dei forums da elaborare
	function lista_forums($forum_id) {
	global $db,$auth;
	$forums_id = array();
	$sql = "SELECT parent_id, forum_id, forum_type FROM " . FORUMS_TABLE . " WHERE parent_id = {$forum_id} || forum_id = ($forum_id)";
	$result = $db->sql_query($sql);

	while($row = $db->sql_fetchrow($result)) {
    		if (!$auth->acl_gets('f_list', 'f_read', $row['forum_id']) === false && $row['forum_type'] == FORUM_POST) 
		{
		$forums_id[] = $row['forum_id'];
    		}
	}
	$db->sql_freeresult($result);
	return $forums_id;
	}

	$lista = lista_forums($forum_id);
	$where_list = '' ;
	foreach($lista as $forum_cor){
		if ($where_list == ''){
		$where_list = $forum_cor ;
		}else{
		$where_list = $where_list . "," . $forum_cor ;
		}
	}
}

// stabilisce il periodo di visualizzazione, 90 gg. per default 
if(!$time_cor){
$time_cor = '90';
}
$time_stamp = ("86400" * $time_cor);
if($time_cor == '1'){
$time_stamp = time() ;
$time_cor = '(Tutti)' ;
}
$data_post = abs(time() - $time_stamp) ;  // è possibile associare questa data alla creazione del Topic o all'ultimo post

$template->assign_vars(array(
        'TIME_COR_STAMP' => $time_cor ,  // stampa automaticamente il numero dei giorni del $time_cor nel template
	  'LISTA_FORUM_COR' => $where_list ,
    ));  
$icons = $cache->obtain_icons();

//QUERY DI SELEZIONE DEI DATI
$sql = "SELECT
pt.topic_id, pt.icon_id, pt.topic_title, pt.topic_views, pt.topic_replies, pt.topic_time, 
pt.topic_moved_id, pt.topic_first_poster_name, pt.topic_poster, pt.topic_first_poster_colour, 
pt.topic_last_poster_id, pt.topic_last_poster_name, pt.topic_last_poster_colour, pt.topic_last_post_time,
pf.parent_id, pf.forum_id, pf.forum_name AS forum_name_cor,
UCASE(LEFT(pt.topic_title, 1)) AS first_char
FROM ". TOPICS_TABLE." pt,". FORUMS_TABLE. " pf
WHERE pt.forum_id IN($where_list)
AND pf.forum_id = pt.forum_id
AND pt.topic_moved_id = 0
AND pt.topic_last_post_time  > $data_post
ORDER BY UCASE(pt.topic_title)";

$db->sql_query($sql);
$result = $db->sql_query($sql);

$current_char = '';
$template->assign_block_vars('topic_list', array(
   'S_FIRST_ROW'  => true,
   'TOPIC_ICON_IMG'   => '',
   'TOPIC_TITLE'   => "%",
   'TOPIC_LINK'   => '',
   'FORUM_NAME'   => "%",
   'TOPIC_AUTHOR'   => "%",
   'VIEWS'        => "%"   
));

$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
while ($row = $db->sql_fetchrow($result))
{
   if (strchr("0123456789", $row['first_char']) && $current_char == ''){
      $current_char = '0';
      $template->assign_block_vars('topic_list', array(
	   'S_FIRST_ROW'  => false,
         'TOPIC_ICON_IMG'   => '',
         'TOPIC_TITLE'   => "0-9",
         'TOPIC_LINK'   => '',
         'TOPIC_AUTHOR'   => '',
         'VIEWS'        => ''
      ));
   } else if (strchr($string, $row['first_char']) ){
      if ($row['first_char'] != $current_char) {
         chapter($current_char, $row['first_char']);
         $current_char = $row['first_char'];
         }
   	}
   
   $template->assign_block_vars('topic_list', array(
	'S_FIRST_ROW'            => false,
      'TOPIC_ICON_IMG'         => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : 'misc/empty.gif',
      'TOPIC_TITLE'            => $row['topic_title'],
      'TOPIC_LINK'             => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't='.$row['topic_id']),
	'FORUM_LINK'		 => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f='.$row['forum_id']),
      'FORUM_NAME_COR'         => $row['forum_name_cor'],
      'VIEWS'         	       => $row['topic_views'],
	'REPLIES'        	       => $row['topic_replies'],
      'TOPIC_AUTHOR'           => $row['topic_first_poster_name'],
      'TOPIC_AUTHOR_FULL'      => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
      'FIRST_POST_TIME'        => $user->format_date($row['topic_time']), //date("d.m.Y",$row['topic_time']),
	'LAST_POST_TIME'		 => $user->format_date($row['topic_last_post_time']), 
      'LAST_POST_AUTHOR_FULL'  => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
   ));
}
$db->sql_freeresult($result);
chapter($current_char, "-");

// Dump out the page header and load template
page_header($user->lang['VIEW_FORUM'] . $forum_name);

$template->set_filenames(array(
   'body' => 'mod_topiclist_body.html')
);
page_footer();

function chapter($start, $current)
{
global $template;

   $letters = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
   $letters_array = explode (",", $letters);
   foreach ($letters_array as $key => $row) {
      if ($row > strtoupper($start)){
         $template->assign_block_vars('topic_list', array(
            'TOPIC_ICON_IMG'      => '',
            'TOPIC_TITLE'   => "$row",
            'TOPIC_LINK'      => '',
            'FORUM_NAME_COR'   => "$row",
         ));
      }
      if ($row == strtoupper($current)){
         return;
      }
   }
}

?>

Re: Lista topic che contengono un certo tag con mod_topiclis

Inviato: 05/07/2010, 17:20
da Carlo
E' da tener prima di tutto conto, che questo che chiedi, dovrà, per ogni topic estratto, ricercare quel tag all'intero del contenuto.

Se i topic sono per esempio 500, ci metterà un bel pò di tempo ad eseguire lo script e quindi mostrare i dati.

Comunque attendiamo bingo...

Re: Lista topic che contengono un certo tag con mod_topiclis

Inviato: 05/07/2010, 18:53
da Micogian
Punto primo: il Topic è la discussione, contiene il Titolo e i dati dell'utente che lo ha creato.
I Posts sono il contenuto delle pagine di un Topic, possono essere naturalmente più di uno e di utenti diversi.
Ora la domanda è questa: dove si trova il tag [incorso][/incorso] ?
Se è nel titolo del Topic la cosa è semplice, se è nei Post la cosa cambia. Non che non sia possibile farlo ma come dice Carlo devi creare una query che controlli tutti i Posts e crei una Lista di quelli che contengono la stringa [incorso].
Stai meno a fare una ricerca con phpmyadmin del tipo

Codice: Seleziona tutto

"SELECT * FROM  'phpbb_posts'  WHERE 'post_text' like '%[incorso]%' "
A questo punto hai a disposizione il topic_id e il post_id del Post e puoi aprire il relativo Topic con l'url
http://tuo_sito/tuo_forum/viewtopic.php?t=xxx dove xxx è il topic_id

Re: Lista topic che contengono un certo tag con mod_topiclis

Inviato: 06/07/2010, 18:43
da Franc[e]sco
E se il tag fosse solo nel primo post di ogni topic? Sarebbe possibile metterlo nella mod?

Re: Lista topic che contengono un certo tag con mod_topiclis

Inviato: 06/07/2010, 21:25
da Micogian
La Mod topiclist fa una ricerca nei Titoli dei Topics, non nei contenuti del Post, sarebbe un'altra cosa.
La domanda che ti devi fare è la seguente: "questa Lista dei Post che contengono il tag [incorso] serve a te per un controllo oppure è utile anche agli utenti ?"
Se la risposta è la prima non serve una Mod, basta un semplice file php che visualizzi la Lista che ti serve utilizzando una query come quella che ti ho indicato, altrimenti va ridisegnata la Mod per ottenere non più una ricerca dei Titoli ma del contenuto dei Post.
Sinceramente in questo periodo non avrei tempo di realizzarla.

Re: Lista topic che contengono un certo tag con mod_topiclis

Inviato: 09/07/2010, 10:43
da Franc[e]sco
Hmmm beh dopotutto serve solo a me e ai moderatori fidati, quindi penso che farò così, grazie ;)