2020-10-08 17:00:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Améliore la sortie print
|
|
|
|
*
|
|
|
|
* @author Tatane http://www.tatane.info/index.php/print_rn
|
|
|
|
* @author http://www.blog.cactuscrew.com/77-print_rn.html
|
|
|
|
* @param $data (array) tableau ou variable à examiner
|
|
|
|
* @param $name (string) nom a afficher
|
|
|
|
* @return false affiche les clef valeur du tableau $data
|
|
|
|
* @example n_print($array, 'Tableau de valeur');
|
|
|
|
*/
|
|
|
|
function n_print($data, $name = '')
|
|
|
|
{
|
|
|
|
$aBackTrace = debug_backtrace();
|
|
|
|
echo '<h2>', $name, '</h2>';
|
|
|
|
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
|
|
|
|
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
|
|
|
|
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
|
|
|
echo '</fieldset><br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
function listDir()
|
|
|
|
{
|
|
|
|
$dirList = array();
|
|
|
|
foreach (glob("content/*", GLOB_ONLYDIR) as $dir) {
|
|
|
|
$dirList[basename($dir)] = listFile($dir);
|
|
|
|
}
|
|
|
|
return $dirList;
|
|
|
|
}
|
|
|
|
|
|
|
|
function listFile($dir)
|
|
|
|
{
|
|
|
|
$fileList = array();
|
|
|
|
foreach (glob($dir . "/*.md") as $dir) {
|
|
|
|
$fileList[] = str_replace('.md', '', basename($dir));
|
|
|
|
}
|
|
|
|
return $fileList;
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeMenu($getDir = null)
|
|
|
|
{
|
|
|
|
$dirList = listDir();
|
|
|
|
$menu = '';
|
|
|
|
foreach ($dirList as $dir => $files) {
|
|
|
|
if ($getDir === $dir) {
|
|
|
|
$expand = 'open';
|
|
|
|
} else {
|
|
|
|
$expand = 'close';
|
|
|
|
}
|
|
|
|
$menu .= '
|
|
|
|
<details ' . $expand . '>
|
|
|
|
<summary>' . $dir . '</summary>
|
|
|
|
<ul>';
|
|
|
|
|
|
|
|
foreach ($files as $value) {
|
|
|
|
$menu .= '<li><a href="/' . urlencode($dir) . '/' . urlencode($value) . '">' . $value . '</a></li>';
|
|
|
|
}
|
|
|
|
$menu .= '
|
|
|
|
</ul>
|
|
|
|
</details>';
|
|
|
|
}
|
|
|
|
return $menu;
|
|
|
|
}
|
2020-10-14 12:18:12 +02:00
|
|
|
|
|
|
|
class ExtendParsedownToc extends ParsedownToc
|
|
|
|
{
|
|
|
|
public function inlineImage($Excerpt)
|
|
|
|
{
|
|
|
|
if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$Excerpt['text'] = substr($Excerpt['text'], 1);
|
|
|
|
|
|
|
|
$Link = $this->inlineLink($Excerpt);
|
|
|
|
|
|
|
|
if ($Link === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$Inline = array(
|
|
|
|
'extent' => $Link['extent'] + 1,
|
|
|
|
'element' => array(
|
|
|
|
'name' => 'img',
|
|
|
|
'attributes' => array(
|
|
|
|
'src' => $Link['element']['attributes']['href'],
|
|
|
|
'alt' => $Link['element']['text'],
|
|
|
|
'loading' => 'lazy',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$Inline['element']['attributes'] += $Link['element']['attributes'];
|
|
|
|
|
|
|
|
unset($Inline['element']['attributes']['href']);
|
|
|
|
|
|
|
|
return $Inline;
|
|
|
|
}
|
|
|
|
}
|