diff --git a/src/paperoption.php b/src/paperoption.php index 4a20473b9..733fdabec 100644 --- a/src/paperoption.php +++ b/src/paperoption.php @@ -1538,15 +1538,8 @@ function validate_document(DocumentInfo $doc) { return false; } - function render(FieldRender $fr, PaperValue $ov) { - if ($this->id <= 0 && $fr->want(FieldRender::CFPAGE)) { - if ($this->id === 0) { - $fr->table->render_submission($fr, $this); - } - return; - } - - $d = $ov->document(0); + /** @param ?DocumentInfo $d */ + static function render_document(FieldRender $fr, PaperOption $opt, $d) { if (!$d) { if ($fr->verbose()) { $fr->set_text("None"); @@ -1559,8 +1552,8 @@ function render(FieldRender $fr, PaperValue $ov) { } else if ($fr->want(FieldRender::CFFORM)) { $fr->set_html($d->link_html(htmlspecialchars($d->filename), 0)); } else if ($fr->want(FieldRender::CFPAGE)) { - $th = $this->title_html(); - $dif = $this->display() === PaperOption::DISP_TOP ? 0 : DocumentInfo::L_SMALL; + $th = $opt->title_html(); + $dif = $opt->display() === PaperOption::DISP_TOP ? 0 : DocumentInfo::L_SMALL; $fr->title = ""; $fr->set_html($d->link_html("{$th}", $dif)); } else { @@ -1573,6 +1566,16 @@ function render(FieldRender $fr, PaperValue $ov) { } } + function render(FieldRender $fr, PaperValue $ov) { + if ($this->id <= 0 && $fr->want(FieldRender::CFPAGE)) { + if ($this->id === 0) { + $fr->table->render_submission($fr, $this); + } + } else { + self::render_document($fr, $this, $ov->document(0)); + } + } + function format_spec() { $speckey = "sub_banal"; if ($this->id) {