getJournalResume();
$html = '
'.$this->escape($journal['titre']).'
'.$this->escape($journal['titre']).'
Archive du journal au '.date("d/m/Y").'.
';
return $html;
}
protected function html_TOC()
{
$this->resetEcrits();
$html = '
Sommaire
';
$cy = $cm = $cd = false;
while ($ecrit = $this->getEcrit())
{
$y = date('Y', $ecrit['date']);
$m = date('Ym', $ecrit['date']);
$d = date('Ymd', $ecrit['date']);
if ($cd && $cd != $d)
{
$html .= '
';
}
if ($cm && $cm != $m)
{
$html .= '';
}
if ($cy && $cy != $y)
{
$html .= '';
}
if ($y != $cy)
{
$cy = $y;
$cm = $cd = false;
$html .= '
'.$this->escape($y).'
';
}
if ($m != $cm)
{
$cd = false;
$cm = $m;
$html .= ''.$this->dateFormat($ecrit['date'], 'F').'
';
}
if ($d != $cd)
{
$cd = $d;
$html .= ''.$this->dateFormat($ecrit['date'], 'l j').'
';
$this->resetEcrits();
return $html;
}
protected function html_Ecrit()
{
$ecrit = $this->getEcrit();
if (!$ecrit)
return false;
$texte = $ecrit['texte_html'];
$url = utils::getJournalURL($this->id);
$preg_url = str_replace('http://', '', $url);
$preg_url = preg_quote($preg_url, '!') . '|' . preg_quote(LENCRIER_ADMIN_HOST, '!');
$texte = preg_replace('!]*src\s*=\s*["\'](https?://[^"\']*)["\'][^>]*>!i', '[Image] \\1', $texte);
$texte = str_replace('allowed_tags))
{
$texte = $this->g2x->process($texte);
}
else
{
$texte = strip_tags($texte, $this->allowed_tags);
}
$html = '
'.$this->escape($ecrit['titre']).'
'.$this->dateFormat($ecrit['date']).'
'.$texte.'
';
return $html;
}
protected function html_Ecrits_pre()
{
return '
';
}
protected function html_Ecrits_post()
{
return '
';
}
protected function html_Footer()
{
return '
';
}
public function export($path=false)
{
if (!$path)
{
$path = LENCRIER_DATA_ROOT . '/documents/'.$this->id.'/export-journal-'.$this->id.'.html';
}
$fp = fopen($path, 'w');
fputs($fp, $this->html_Header());
fputs($fp, $this->html_TOC());
fputs($fp, $this->html_Ecrits_pre());
stream_context_get_default(array(
'http' => array(
'method' => 'HEAD',
'max_redirects' => 2,
'timeout' => 5,
)));
$this->http_context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'max_redirects' => 2,
'timeout' => 5,
)));
require_once LENCRIER_ROOT . '/include/garbage2xhtml/lib.garbage2xhtml.php';
$this->g2x = new garbage2xhtml;
// Les navigateurs ont gravement régressé
// Il n'est plus possible d'empêcher le chargement d'un média externe avec display: none
// Du coup ça bloque tout, donc on ne les affiche tout bêtement pas
unset($this->g2x->block_tags['audio'], $this->g2x->block_tags['video'],
$this->g2x->block_tags['object'], $this->g2x->block_tags['iframe']);
// Si le nombre d'écrits est trop important on utilise strip_tags sinon ça sera trop lent !
if ($this->nbEcrits() > 1000)
{
$this->allowed_tags = array_merge(
array_keys($this->g2x->block_tags),
array_keys($this->g2x->inline_tags)
);
$this->allowed_tags = '<' . implode('><', $this->allowed_tags) . '>';
}
while ($html = $this->html_Ecrit())
{
fputs($fp, $html);
}
fputs($fp, $this->html_Ecrits_post());
fputs($fp, $this->html_Footer());
fclose($fp);
}
static public function Archive($id)
{
$export = new Journal_HTML_Export($id);
$export->export(LENCRIER_ROOT . '/archives/' . date('Y-m-d-') . $id . '.html');
}
}
?>