Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
// $Id: ezmlm-threads.php,v 1.6 2008-08-25 15:19:15 alexandre_tb Exp $
|
2 |
// $Id: ezmlm-threads.php,v 1.7 2008-11-19 09:28:46 aperonnet Exp $
|
3 |
//
|
3 |
//
|
4 |
// ezmlm-threads.php - ezmlm-php v2.0
|
4 |
// ezmlm-threads.php - ezmlm-php v2.0
|
5 |
// --------------------------------------------------------------
|
5 |
// --------------------------------------------------------------
|
6 |
// Builds, maintains & displays thread caches
|
6 |
// Builds, maintains & displays thread caches
|
7 |
// These cache files live in $ezmlm->tmpdir and are serialized
|
7 |
// These cache files live in $ezmlm->tmpdir and are serialized
|
Line 35... |
Line 35... |
35 |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) {
|
35 |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) {
|
36 |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n";
|
36 |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n";
|
37 |
$this->build($month);
|
37 |
$this->build($month);
|
38 |
}
|
38 |
}
|
39 |
}
|
39 |
}
|
40 |
$this->display($month);
|
40 |
$html = $this->display($month);
|
- |
|
41 |
return $html ;
|
41 |
}
|
42 |
}
|
Line 42... |
Line 43... |
42 |
|
43 |
|
43 |
// display: this loads each cache file sequentially and displays the messages in them
|
44 |
// display: this loads each cache file sequentially and displays the messages in them
|
44 |
// there is no checking of checksum's done here so load() is the preferred method to
|
45 |
// there is no checking of checksum's done here so load() is the preferred method to
|
45 |
// view the threads
|
46 |
// view the threads
|
- |
|
47 |
function display($month) {
|
46 |
function display($month) {
|
48 |
$html = '' ;
|
47 |
$seq = 0;
|
49 |
$seq = 0;
|
48 |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) {
|
50 |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) {
|
49 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month;
|
51 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month;
|
50 |
} else {
|
52 |
} else {
|
51 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month;
|
53 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month;
|
52 |
}
|
54 |
}
|
53 |
// Le lien par date et par thread
|
55 |
// Le lien par date et par thread
|
54 |
echo '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ;
|
56 |
$html .= '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ;
|
- |
|
57 |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
|
55 |
$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
58 |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
|
56 |
// remplacé par le tableau globals $mois dans ezmlm.php
|
59 |
// remplacé par le tableau globals $mois dans ezmlm.php
|
Line 57... |
Line 60... |
57 |
print '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
|
60 |
$html .= '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1) -1] .', ' . substr($month,0,4) . '</h2>'."\n";
|
58 |
|
61 |
|
59 |
print '<table class="table_cadre">'."\n";
|
62 |
$html .= '<table class="table_cadre">'."\n";
|
60 |
print '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
63 |
$html .= '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
Line 61... |
Line 64... |
61 |
print '<tr><td colspan="3"><hr /></td></tr>'."\n";
|
64 |
$html .= '<tr><td colspan="3"><hr /></td></tr>'."\n";
|
62 |
$ctc = 0;
|
65 |
$ctc .= 0;
|
63 |
|
66 |
|
64 |
if (is_file($cache)) {
|
67 |
if (is_file($cache)) {
|
65 |
include($cache);
|
68 |
include($cache);
|
- |
|
69 |
}
|
- |
|
70 |
$html .= '<tr><td colspan="3"></td></tr>'."\n";
|
66 |
}
|
71 |
$html .= '</table>'."\n";
|
Line 67... |
Line 72... |
67 |
print '<tr><td colspan="3"></td></tr>'."\n";
|
72 |
|
68 |
print '</table>'."\n";
|
73 |
return $html ;
|
Line 120... |
Line 125... |
120 |
}
|
125 |
}
|
Line 121... |
Line 126... |
121 |
|
126 |
|
122 |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n";
|
127 |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n";
|
123 |
return $html;
|
128 |
return $html;
|
- |
|
129 |
}
|
- |
|
130 |
|
- |
|
131 |
// TODO: Fonction à tester et compléter
|
- |
|
132 |
// Construit un index de tous les messages envoyés dans une liste donnée pour un mois
|
- |
|
133 |
// au format YYYYMM
|
- |
|
134 |
function build_month_list($date)
|
- |
|
135 |
{
|
- |
|
136 |
$months = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug',
|
- |
|
137 |
9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec');
|
- |
|
138 |
|
- |
|
139 |
$month = $months[((int)substr($month,4,2) / 1) -1] ;
|
- |
|
140 |
$year = substr($month,0,4) ;
|
- |
|
141 |
$numArchive = $this->getNumArchive();
|
- |
|
142 |
$dernierRepertoire = floor($numArchive / 100);
|
- |
|
143 |
|
- |
|
144 |
$threads = array();
|
- |
|
145 |
|
- |
|
146 |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) {
|
Line -... |
Line 147... |
- |
|
147 |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES);
|
- |
|
148 |
|
- |
|
149 |
// On parcourt le fichier a l envers
|
- |
|
150 |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) {
|
- |
|
151 |
$match = strpos($fichier_index[$j],$month.' '.$year) ;
|
- |
|
152 |
if ($match) {
|
- |
|
153 |
|
- |
|
154 |
$threads[] = $fichier_index[$j-1] ;
|
- |
|
155 |
|
- |
|
156 |
}
|
- |
|
157 |
}
|
- |
|
158 |
}
|
124 |
}
|
159 |
}
|
125 |
|
160 |
|
126 |
// build: takes one argument in the format YYYYMM and builds the thread cache file
|
161 |
// build: takes one argument in the format YYYYMM and builds the thread cache file
|
127 |
// for that month if the ezmlm thread file exists. The resulting cache file is then
|
162 |
// for that month if the ezmlm thread file exists. The resulting cache file is then
|
128 |
// stored in $this->tmpdir;
|
163 |
// stored in $this->tmpdir;
|
Line 250... |
Line 285... |
250 |
return TRUE;
|
285 |
return TRUE;
|
251 |
}
|
286 |
}
|
Line 252... |
Line 287... |
252 |
|
287 |
|
253 |
// listmessages: prints out a nice little calendar and displays the message
|
288 |
// listmessages: prints out a nice little calendar and displays the message
|
254 |
// totals for each month. The link jumps to the thread listing.
|
289 |
// totals for each month. The link jumps to the thread listing.
|
255 |
// On lit le repetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet
|
290 |
// On lit le repertoire archive/threads/ qui contient un fichier par mois avec tous les thread, par sujet
|
256 |
// Presentes comme suit
|
291 |
// Presentes comme suit
|
257 |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
|
292 |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
|
258 |
// les messages sont ranges par leur numero
|
293 |
// les messages sont ranges par leur numero
|
259 |
function listmessages() {
|
294 |
function listmessages() {
|
Line 390... |
Line 425... |
390 |
// On ajoute la derniere annee
|
425 |
// On ajoute la derniere annee
|
391 |
$html .= $this->calculeCalendrierPermanent(date ('Y'));
|
426 |
$html .= $this->calculeCalendrierPermanent(date ('Y'));
|
Line 392... |
Line 427... |
392 |
|
427 |
|
393 |
if ($this->isFichierCalendrierExiste()) {
|
428 |
if ($this->isFichierCalendrierExiste()) {
|
394 |
// S il existe mais qu il est trop vieux, il faut le recalculer
|
429 |
// S il existe mais qu il est trop vieux, il faut le recalculer
|
395 |
if ($this->isDoitRecalculerCalendrier()) {
|
430 |
// if ($this->isDoitRecalculerCalendrier()) {
|
396 |
$annees = $this->getAnneesARecalculer();
|
431 |
$annees = $this->getAnneesARecalculer();
|
397 |
$html .= $this->calculeCalendrierPermanent($annees);
|
432 |
$html .= $this->calculeCalendrierPermanent($annees);
|
398 |
}
|
433 |
// }
|
399 |
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier');
|
434 |
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier');
|
400 |
} else {
|
435 |
} else {
|
401 |
$html .= $this->ecrireFichierCalendrier();
|
436 |
$html .= $this->ecrireFichierCalendrier();
|
402 |
}
|
437 |
}
|