| Server IP : 165.22.154.248 / Your IP : 216.73.217.0 [ Web Server : Apache/2.4.29 (Ubuntu) System : Linux droplet-integra 4.15.0-197-generic #208-Ubuntu SMP Tue Nov 1 17:23:37 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 7.2.24-0ubuntu0.18.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/avanza-lms.old.bak9874115/mod/wiki/parser/ |
Upload File : |
<?php
/**
* Parser utils and default callbacks.
*
* @author Josep ArĂºs
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_wiki
*/
require_once($CFG->dirroot . "/lib/outputcomponents.php");
class parser_utils {
public static function h($tag, $text = null, $options = array(), $escape_text = false) {
$tag = htmlentities($tag, ENT_COMPAT, 'UTF-8');
if(!empty($text) && $escape_text) {
$text = htmlentities($text, ENT_COMPAT, 'UTF-8');
}
return html_writer::tag($tag, $text, $options);
}
/**
* Default link generator
*/
public static function wiki_parser_link_callback($link, $options) {
$l = urlencode($link);
if(!empty($options['anchor'])) {
$l .= "#".urlencode($options['anchor']);
}
return array('content' => $link, 'url' => "http://".$l);
}
/**
* Default table generator
*/
public static function wiki_parser_table_callback($table) {
$html = "";
$headers = $table[0];
$columncount = count($headers);
$headerhtml = "";
foreach($headers as $h) {
$text = trim($h[1]);
if($h[0] == 'header') {
$headerhtml .= "\n".parser_utils::h('th', $text)."\n";
$hasheaders = true;
}
else if($h[0] == 'normal'){
$headerhtml .= "\n".parser_utils::h("td", $text)."\n";
}
}
$headerhtml = "\n".parser_utils::h('tr', $headerhtml)."\n";
$bodyhtml = "";
if(isset($hasheaders)) {
$html = "\n".parser_utils::h('thead', $headerhtml)."\n";
}
else {
$bodyhtml .= $headerhtml;
}
array_shift($table);
foreach($table as $row) {
$htmlrow = "";
for($i = 0; $i < $columncount; $i++) {
$text = "";
if(!isset($row[$i])) {
$htmlrow .= "\n".parser_utils::h('td', $text)."\n";
}
else {
$text = trim($row[$i][1]);
if($row[$i][0] == 'header') {
$htmlrow .= "\n".parser_utils::h('th', $text)."\n";
}
else if($row[$i][0] == 'normal'){
$htmlrow .= "\n".parser_utils::h('td', $text)."\n";
}
}
}
$bodyhtml .= "\n".parser_utils::h('tr', $htmlrow)."\n";
}
$html .= "\n".parser_utils::h('tbody', $bodyhtml)."\n";
return "\n".parser_utils::h('table', $html)."\n";
}
/**
* Default path converter
*/
public static function wiki_parser_real_path($url) {
return $url;
}
}