1,5 → 1,5 |
<?php |
// $Id: ezmlm-threads.php,v 1.5 2007-04-19 15:34:35 neiluj Exp $ |
// $Id: ezmlm-threads.php,v 1.6 2008-08-25 15:19:15 alexandre_tb Exp $ |
// |
// ezmlm-threads.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
252,18 → 252,28 |
|
// listmessages: prints out a nice little calendar and displays the message |
// totals for each month. The link jumps to the thread listing. |
// On lit le répertoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet |
// Présentés comme suit |
// On lit le repetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet |
// Presentes comme suit |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier) |
// les messages sont rangés par leur numéro |
// les messages sont ranges par leur numero |
function listmessages() { |
if (!is_dir($this->listdir . "/archive/threads/")) { |
return false ; |
} |
|
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
$res .= $this->calendrierMessage(); |
$res .= "</table>\n"; |
return $res; |
/* |
$threadcount = array(); |
|
$repertoire_archive = opendir($this->listdir . "/archive/"); |
|
$tableau_annee = array(); |
while (false !== ($item = readdir($repertoire_archive))) { |
// $item contient les noms des repertoires |
// on ne garde que ceux qui sont des chiffres |
280,39 → 290,137 |
$temp = fgets($fichier_index, 4096); |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ; |
if ($match[0] != '') { |
|
$threadmonth = date('n', strtotime($match[0])) ; |
$threadyear = date('Y', strtotime($match[0])) ; |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
fclose ($fichier_index); |
} |
} |
|
// La partie qui suit, simple, crée la table avec le nombre de message échangé chaque mois |
if (count($threadcount) == 0) return 'Il n\y a pas de messages dans les archives'; |
// La partie qui suit, simple, cree la table avec le nombre de message echange chaque mois |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<td>'.$valeur.'</td>' ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
|
while (list($key,$val) = each($threadcount)) { |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= " <td>$key</td>"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
if (isset($threadcount[$key][$i]) && $threadcount[$key][$i] > 0) { |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">"; |
$res .= $this->makelink('action=show_month&actionargs[]='.$key.($i < 10 ? '0'.$i:$i),$threadcount[$key][$i]); |
$res .= "</td>"; |
} else { |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>"; |
} |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= "</tr>\n"; |
$res .= '</tr>'."\n"; |
} |
$res .= "</table>\n"; |
echo $res ; |
return $res ; |
*/ |
} |
/* |
* Cree un fichier liste.calendrierPermanent qui contient |
* le nombre de message par mois pour toutes les annees |
* depuis le debut de la liste sauf la derniere |
* |
*/ |
function calculeCalendrierPermanent($Annnee = '') { |
$numArchive = $this->getNumArchive(); |
$dernierRepertoire = floor($numArchive / 100); |
|
$threadcount = array(); |
$tableau_annee = array(); |
|
|
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) { |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES); |
|
// On parcours le fichier a l envers |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) { |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $fichier_index[$j], $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])) ; |
$threadyear = date('Y', strtotime($match[0])) ; |
if ($Annnee != '') { |
if ($threadyear < date('Y')) { |
$sortir = true; |
break; |
} |
} else { |
if ($threadyear == date('Y')) continue; |
} |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
if ($sortir) break; |
} |
$res = ''; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
return $res; |
} |
function ecrireFichierCalendrier() { |
$html = $this->calculeCalendrierPermanent(); |
$f = fopen ('tmp/'.$this->listname.'.calendrier', 'w') ; |
fwrite ($f, $html); |
fclose($f); |
return $html; |
} |
|
function calendrierMessage() { |
$html = ''; |
// On ajoute la derniere annee |
$html .= $this->calculeCalendrierPermanent(date ('Y')); |
|
if ($this->isFichierCalendrierExiste()) { |
// S il existe mais qu il est trop vieux, il faut le recalculer |
if ($this->isDoitRecalculerCalendrier()) { |
$annees = $this->getAnneesARecalculer(); |
$html .= $this->calculeCalendrierPermanent($annees); |
} |
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier'); |
} else { |
$html .= $this->ecrireFichierCalendrier(); |
} |
return $html; |
} |
|
function isFichierCalendrierExiste() { |
if (file_exists('tmp/'.$this->listname.'.calendrier')) { |
return true; |
} |
return false; |
} |
function isDoitRecalculerCalendrier() { |
|
if (date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')) != date('Y')) return true; |
return false; |
} |
|
function getAnneesARecalculer() { |
// On suppose que l index de ezmlm est correct |
$anneeFichierCalendrier = date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')); |
return $anneeFichierCalendrier + 1; |
} |
|
} |
|
// CLASS: ezmlm-thread is a quick little class to allow us to define |