. /** * Admin HTML for Adobe Connect server setup guide. * * @package mod_meetletacbmarketplace * @copyright 2026 MeetLet * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_meetletacbmarketplace\local; defined('MOODLE_INTERNAL') || die(); /** * Renders the “Server setup” admin help tab. */ class server_guide { /** * Build guide HTML (safe for admin settings heading). */ public static function render(): string { $plugin = 'meetletacbmarketplace'; $httpauth = config::get_http_auth_header(); $current = \html_writer::tag('h4', get_string('serverguide_current_title', $plugin)) . \html_writer::tag('p', get_string('serverguide_current_intro', $plugin)) . self::table([ [get_string('admin_httpauth', $plugin), \html_writer::tag('code', s($httpauth))], [get_string('host', $plugin), \html_writer::tag('code', s(config::get_api_url() !== '' ? config::get_api_url() : '—'))], [get_string('meethost', $plugin), \html_writer::tag('code', s(config::get_meet_host() !== '' ? config::get_meet_host() : '—'))], ]); $customini = self::section( 'customini', get_string('serverguide_customini_title', $plugin), get_string('serverguide_customini_body', $plugin) . \html_writer::tag('pre', s(get_string('serverguide_customini_sample', $plugin, $httpauth)), [ 'class' => 'meetlet-guide__code', ]) ); $webxml = self::section( 'webxml', get_string('serverguide_webxml_title', $plugin), get_string('serverguide_webxml_body', $plugin) . \html_writer::tag('pre', s(get_string('serverguide_webxml_sample', $plugin)), [ 'class' => 'meetlet-guide__code', ]) ); $serverxml = self::section( 'serverxml', get_string('serverguide_serverxml_title', $plugin), get_string('serverguide_serverxml_body', $plugin) . \html_writer::tag('pre', s(get_string('serverguide_serverxml_sample', $plugin)), [ 'class' => 'meetlet-guide__code', ]) ); $upgrade = \html_writer::div( \html_writer::tag('strong', get_string('serverguide_upgrade_title', $plugin)) . \html_writer::div(get_string('serverguide_upgrade_body', $plugin), 'meetlet-guide__body'), 'meetlet-guide__callout meetlet-guide__callout--warn', ['id' => 'meetlet-guide-upgrade'] ); $codes = self::errorcodes_section(); return \html_writer::div( \html_writer::tag('h3', get_string('serverguide_heading', $plugin), ['class' => 'meetlet-guide__heading']) . \html_writer::tag('p', get_string('serverguide_intro', $plugin), ['class' => 'meetlet-guide__intro']) . \html_writer::div($current, 'meetlet-guide__section meetlet-guide__section--current') . $customini . $webxml . $serverxml . $upgrade . $codes, 'meetlet-guide meetlet-settings-card' ); } /** * Help-code table so an admin can match a student-reported ML- code. */ protected static function errorcodes_section(): string { $plugin = 'meetletacbmarketplace'; $head = \html_writer::tag('tr', \html_writer::tag('th', get_string('serverguide_errorcodes_col_code', $plugin)) . \html_writer::tag('th', get_string('serverguide_errorcodes_col_meaning', $plugin)) . \html_writer::tag('th', get_string('serverguide_errorcodes_col_fix', $plugin)) ); $body = ''; foreach (usererror::catalog() as $item) { $body .= \html_writer::tag('tr', \html_writer::tag('td', \html_writer::tag('code', s($item['label'])), ['class' => 'meetlet-guide__code-cell']) . \html_writer::tag('td', get_string($item['titlekey'], $plugin)) . \html_writer::tag('td', get_string($item['fixkey'], $plugin)) ); } $table = \html_writer::tag( 'table', \html_writer::tag('thead', $head) . \html_writer::tag('tbody', $body), ['class' => 'meetlet-guide__table generaltable'] ); return self::section( 'errorcodes', get_string('serverguide_errorcodes_title', $plugin), \html_writer::tag('p', get_string('serverguide_errorcodes_intro', $plugin)) . $table ); } /** * @param string $id Section id for anchoring. * @param string $title Section title. * @param string $bodyhtml Trusted HTML from lang strings (admin-only). */ protected static function section(string $id, string $title, string $bodyhtml): string { return \html_writer::div( \html_writer::tag('h4', $title) . \html_writer::div($bodyhtml, 'meetlet-guide__body'), 'meetlet-guide__section', ['id' => 'meetlet-guide-' . $id] ); } /** * @param array $rows Label / value (value may contain HTML). */ protected static function table(array $rows): string { $trs = ''; foreach ($rows as $row) { $trs .= \html_writer::tag( 'tr', \html_writer::tag('th', $row[0], ['scope' => 'row']) . \html_writer::tag('td', $row[1]) ); } return \html_writer::tag( 'table', \html_writer::tag('tbody', $trs), ['class' => 'meetlet-guide__table generaltable'] ); } }