/** * Displays a blob document *inline* (if possible, depending on the type of the document) * @return string */ public function DisplayDocumentInline(WebPage $oPage, $sAttCode) { $oDoc = $this->Get($sAttCode); $sClass = get_class($this); $Id = $this->GetKey(); switch ($oDoc->GetMainMimeType()) { case 'text': case 'html': $data = $oDoc->GetData(); switch ($oDoc->GetMimeType()) { case 'text/html': case 'text/xml': $oPage->add("<iframe id='preview_{$sAttCode}' src=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=display_document&class={$sClass}&id={$Id}&field={$sAttCode}\" width=\"100%\" height=\"400\">Loading...</iframe>\n"); break; default: $oPage->add("<pre>" . htmlentities(MyHelpers::beautifulstr($data, 1000, true), ENT_QUOTES, 'UTF-8') . "</pre>\n"); } break; case 'application': switch ($oDoc->GetMimeType()) { case 'application/pdf': $oPage->add("<iframe id='preview_{$sAttCode}' src=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=display_document&class={$sClass}&id={$Id}&field={$sAttCode}\" width=\"100%\" height=\"400\">Loading...</iframe>\n"); break; default: $oPage->add(Dict::S('UI:Document:NoPreview')); } break; case 'image': $oPage->add("<img src=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=display_document&class={$sClass}&id={$Id}&field={$sAttCode}\" />\n"); break; default: $oPage->add(Dict::S('UI:Document:NoPreview')); } }
public function __toString() { return MyHelpers::beautifulstr($this->m_data, 100, true); }