public function document_content(PaperInfo $prow, $index) { if (($doc = $this->document($prow, $index)) && $doc->docclass->load($doc) && ($content = Filer::content($doc))) { return $content; } return false; }
public function document_to_json($dtype, $docid) { global $Conf; if (!is_object($docid)) { $dresult = $Conf->document_result($this->paperid, $dtype, $docid); $drow = $Conf->document_row($dresult, $dtype); Dbl::free($dresult); } else { $drow = $docid; $docid = $drow ? $drow->paperStorageId : null; } $d = (object) array(); if ($docid && !$this->hide_docids) { $d->docid = $docid; } if ($drow) { if ($drow->mimetype) { $d->mimetype = $drow->mimetype; } if ($drow->sha1 !== null && $drow->sha1 !== "") { $d->sha1 = bin2hex($drow->sha1); } if ($drow->timestamp) { $d->timestamp = (int) $drow->timestamp; } if (get($drow, "filename")) { $d->filename = $drow->filename; } $meta = null; if (isset($drow->infoJson) && is_object($drow->infoJson)) { $meta = $drow->infoJson; } else { if (isset($drow->infoJson) && is_string($drow->infoJson)) { $meta = json_decode($drow->infoJson); } } if ($meta) { $d->metadata = $meta; } if ($this->export_content && $drow->docclass->load($drow)) { $d->content_base64 = base64_encode(Filer::content($drow)); } } foreach ($this->document_callbacks as $cb) { call_user_func($cb, $d, $this->prow, $dtype, $drow); } if (!count(get_object_vars($d))) { $d = null; } return $d; }