problem = $problem; $this->data_zip = new ZipArchive; $ret = $this->data_zip->open($this->problem->getDataZipPath(), ZipArchive::RDONLY); if ($ret !== true) { UOJLog::error('zip open failed: ', $this->problem->getDataZipPath(), $ret); } $this->data_zip_root = $this->problem->info['id'] . '/'; $this->finfo = new finfo(FILEINFO_MIME_ENCODING); for ($i = 0; $i < $this->data_zip->count(); $i++) { $name = $this->data_zip->getNameIndex($i); if (strStartWith($name, $this->data_zip_root) && !strEndWith($name, '/')) { $this->rest_data_files[substr($name, strlen($this->data_zip_root))] = true; } } } public function setProblemConf(array $problem_conf) { foreach ($problem_conf as $key => $val) { $this->problem_conf[$key] = ['val' => $val]; } } public function setProblemConfRowStatus($key, $status) { $this->problem_conf[$key]['status'] = $status; return $this; } public function addTab($file_name, $fun) { $this->tabs[$file_name] = $fun; return $this; } public function echoAllTabs($active_tab) { $rest = array_keys($this->rest_data_files); natsort($rest); foreach (array_merge(array_keys($this->tabs), $rest) as $tab) { if ($tab !== $active_tab) { echo '
', "\n"; $type = $mimetype == 'binary' ? 'binary' : 'text'; echo HTML::escape(uojStringPreview($content, $max_len, $type)); echo "\n"; } public function echoProblemConfTable() { echo '
key | '; echo 'value | '; echo '
---|---|
', HTML::escape($key), ' | '; echo '', HTML::escape($val), ' | '; echo '
', HTML::escape($key), ' | '; echo '', HTML::escape($val), ' ', ' | '; echo '