Classe : \Schwan\Code\View\Source

Fichier PHP
| Mardi 12 Mars 2024, 18:17:50

<?php
/**
* Code.Schwan
*
* GNU General Public License
*
* Copyright © 2021 - 2023, Yohann Schwan. All rights reserved.
*/
namespace Schwan\Code\View {

class
Source extends \Lys\View
{
/**
* @args string $str = ''
* @return void
*/
function send($str = '')
{
foreach(
$this->listOf('source') as $row)
{
$row = $this->sourceOf($row);

$this['self'] = array(

'title' => $row['source_title'],
'subtitle' => 'Fichier ' . strtoupper($row['source_type']),
'date' => $row['source_time'],
);
}

$p = array(

"\r", "\n",
// '&nbsp;&nbsp;',
'&nbsp;',
/* '<> ',
'<>',
'<br />', '<br> ',
*/
'<code>', '</code>'
);

$q = array(

'', '',
// '<>',
' ',
/* '<span class="hs">&nbsp;&nbsp;&nbsp;</span>',
'<span class="hs">&nbsp;&nbsp;</span>',
'<br>', '<br>&nbsp;',
*/
'<div class="c6 code">', '</div>'
);

$type = $row['source_type'];
$path = $row['source_path'];

if(
'php' == $type)
{
$str .= ''
. (file_exists($path)
?
''
. '<div class="inner">'
. str_replace($p, $q, highlight_file($path, true))
.
'</div>'
: ''
);
}
else {

$str .= ''
. (file_exists($path)
?
''
. '<div class="inner">'
. str_replace($p + array(
8 => '<span style="color: #FF8000">#',
9 => '<span style="color: #0000BB">&lt;?php<br /></span>'), $q + array(
8 => '<span style="color: #0000BB">#',
9 => ''), highlight_string('<?php' . "\n" . file_get_contents($path), true))
.
'</div>'
: ''
);
}

return
parent::send($str);
}
}
}