<?php
class myBlock extends control
{
    public function printParamsBlock($blockID)
    {
        $block = $this->block->getByID($blockID);
        if(empty($block)) return false;

        $this->app->loadLang('im');

        $html = '<div><table class="table table-form table-borderless">';

        $key = zget($this->config->xuanxuan, 'key', '');
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->xxdServer.'</strong></td><td class="code">'.$this->loadModel('im')->getServer().'</td></tr>';
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->key.'</strong></td><td class="code">'.(strlen($key) > 8 ? (substr($key, 0, 4).'...'.substr($key, -4)) : $key).'</td>';
        $debug = zget($this->config->xuanxuan, 'debug', 0);
        $html .= '    <td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->debug.'</strong></td><td style="padding: 4px 7px 2px 7px;">'.zget($this->lang->im->debugStatus, $debug).'</td></tr>';
        $https = zget($this->config->xuanxuan, 'https', 'off');
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->xxd->https.'</strong></td><td style="padding: 4px 7px 2px 7px;">'.zget($this->lang->im->httpsOptions, $https).'</td>';
        $html .= '    <td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->xxd->ip.'</strong></td><td class="code">'.zget($this->config->xuanxuan, 'ip', '0.0.0.0').'</td></tr>';
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->xxd->chatPort.'</strong></td><td class="code">'.zget($this->config->xuanxuan, 'chatPort', 11444).'</td>';
        $html .= '    <td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->xxd->commonPort.'</strong></td><td class="code">'.zget($this->config->xuanxuan, 'commonPort', 11444).'</td></tr>';
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->xxd->uploadFileSize.'</strong></td><td style="padding: 4px 7px 2px 7px;">'.$this->lang->im->xxd->max.zget($this->config->xuanxuan, 'uploadFileSize', 20).'M'.'</td>';
        $html .= '    <td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->im->pollingInterval.'</strong></td><td class="code">'.zget($this->config->xuanxuan, 'pollingInterval', 60).'</td></tr>';
        $this->app->loadLang('conference');
        $jitsiEnabled = $this->loadModel('setting')->getItem("owner=system&module=jitsi&section=common&key=enabled");
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->conference->enabled.'</strong></td><td class="code">'.(!empty($jitsiEnabled) && $jitsiEnabled != 'false' ? $this->lang->im->enabled : $this->lang->im->disabled).'</td>';
        $this->app->loadLang('push');
        $pushEnabled = $this->setting->getItem("owner=system&module=push&section=common&key=enable");
        $html .= '    <td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->push->enable.'</strong></td><td class="code">'.(!empty($pushEnabled) && $pushEnabled != 'close' ? $this->lang->im->enabled : $this->lang->im->disabled).'</td></tr>';
        $this->app->loadLang('integration');
        $officeEnabled = $this->setting->getItem("owner=system&module=integration&section=office&key=officeEnabled");
        $html .= '<tr><td style="padding: 4px 7px 2px 7px;"><strong>'.$this->lang->integration->office.'</strong></td><td style="padding: 4px 7px 2px 7px;">'.(!empty($officeEnabled) && $officeEnabled != '0' ? $this->lang->im->enabled : $this->lang->im->disabled).'</td>';

        $html .= '<td style="padding: 4px 7px 2px 7px;" align="right">'.html::a(helper::createLink('setting', 'downloadXXD', 'type=config'), $this->lang->im->downloadConf, "class='btn btn-sm btn-primary download' target='hiddenwin'").'</td>';
        $html .= '<td style="padding: 4px 7px 2px 7px;" align="center">'.html::a(helper::createLink('setting', 'xuanxuan', 'type=edit'), $this->lang->im->changeSetting, "class='btn btn-sm'").'</td></tr>';

        $html .= '</table></div>';

        die($html);
    }
}
