Ho modificato la classe in modo tale da avere solo una funzione.
Codice PHP:
<?php
class news
{
var $param;
var $id;
function news(){
if($this->param=="mostra"||$this->param==""){
$MySql = "SELECT COUNT(id) AS totale FROM news";
$query = mysql_query ($MySql) or die ( "Non riesco ad eseguire la richiesta $MySql");
while ($valori = mysql_fetch_array ($query)){
// numero totale di records
$tot_records = $valori["totale"];
}
// risultati per pagina(secondo parametro di LIMIT)
$per_page = 5;
// numero totale di pagine
$tot_pages = ceil($tot_records / $per_page);
// pagina corrente
if ($this->id == "") {
$leo = "1";
} else {
$leo = $this->id;
}
$current_page = (!$leo) ? 1 : (int)$leo;
$query='SELECT * FROM news ORDER BY id ASC LIMIT 0,5';
$q=mysql_query($query);
$news .='<div align="left"><ul id="newslist">';
while($res=mysql_fetch_array($q)){
if($res['comments_id'] == '0'){
$descrizione=$res['description'];
$descrizione .= @eregi_replace('/\[(quote)\](.*?)\[\/(quote)\]/is','<div id="quote">$2</div>',$descrizione);
$news .='[*]<div id="news">
<table width="75%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" height="16" valign="top">'.$res['title'].'</td>
<td width="25%" valign="top">Data : '.$res['date'].'</td>
</tr>
<tr>
<td height="49" colspan="2" valign="top">'.$descrizione.'</td>
</tr>
</table>
</div><hr>';
} else {
$news .='[*]<div id="news">
<table width="75%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" height="16" valign="top">'.$res['title'].'</td>
<td width="25%" valign="top">Data : '.$res['date'].'</td>
</tr>
<tr>
<td height="49" colspan="2" valign="top">'.$res['description'].'</td>
</tr>
<td height="17" colspan="2" valign="top">[url="javascript:callAHAH(\'index.php?idnews='.$res['id'].'&page=main&func=comments\',\'tcc\',\'<img src=immagini/loading.gif border=0>\',\'Error:\')"]Commenti[/url]</td>
</table>
</div>';
}
}
$paginazione = "Pagine totali: " . $tot_pages . "
[";
for($i = 1; $i <= $tot_pages; $i++) {
if($i == $current_page) {
$paginazione .= $i . " ";
} else {
$paginazione .= '|<a href=\"javascript:callAHAH(\'index.php?id=$i&page=main\',\'content\',\'<img src=immagini/loading.gif border=0>\',\'Error:\')\" title=\"Vai alla pagina $i\">$i</a>|';
}
}
$paginazione .= "]";
$news .='[/list]<div>'.$paginazione.'</div></div>';
} elseif($this->param=="comment") {
$MySql='SELECT * FROM comments WHERE idnews="'.$param.'" ORDER BY idnews ASC LIMIT 0,5';
$query=mysql_query($MySql) or die(mysql_error());
while($result=mysql_fetch_array($query) or die(mysql_error())){
$news ='<div id="comments">'.$result['description'].'</div><hr />';
}
}
return $news;
}
}
?>
la funzione è richiamata così:
Codice PHP:
<?php
include('includes/php/news.class.php');
$news=new news;
$news->id=@$_GET['id'];
$news->param=@$_GET['func'];
$func=$news->news();
$smarty->assign('news',$func);
?>

grazie in anticipo.