This commit is contained in:
Dr Masroor Ehsan 2025-01-12 13:17:35 +06:00
parent bfbed52332
commit c6bb55862c
18 changed files with 313 additions and 230 deletions

View File

@ -7,6 +7,7 @@
use App\Http\Requests\StoreReportRequest;
use App\Models\Study;
use App\Services\Report\ReportManager;
use App\Services\Report\StampService;
class ReportController extends HashidControllerBase
{
@ -80,9 +81,17 @@ public function view(string $uuid)
{
ReportManager::ensureDownloadAccess();
$manager = ReportManager::fromReport($uuid);
$title = 'View Report';
$title = 'Report Quick View ' . $manager->getStudy()->getPatientDemographic();
$report = $manager->getReport();
if ($report->isFinalized()) {
$stamper = new StampService($report->read_by_id);
$signature = $stamper->hasSignatureImage() ? $stamper->signatureImageUrl() : null;
$notice = null;
} else {
$signature = null;
$notice = 'This is a preliminary radiology interpretation that has not been finalized or approved by a radiologist. It is not intended for diagnostic purposes.';
}
return view('staff.reports.viewer.html-report', compact('report', 'title'));
return view('staff.reports.viewer.html-report', compact('report', 'title', 'signature', 'notice'));
}
}

View File

@ -126,6 +126,11 @@ public function canEdit(User|int|null $user = null): bool
return false;
}
public function isFinalized(): bool
{
return $this->report_status->value >= ReportStatus::Finalized->value;
}
/**
* @return array<string, string>
*/

View File

@ -7,8 +7,8 @@
use App\Models\StudyReport;
use app\Services\Export\Formats\HtmlExport;
use app\Services\Export\Formats\PdfExport;
use app\Services\Export\Formats\Word2007Export;
use app\Services\Export\Formats\Word2003Export;
use app\Services\Export\Formats\Word2007Export;
final readonly class Exporters
{

View File

@ -21,7 +21,7 @@ public static function make(int $study_id, ?StudyReport $report = null): static
public static function fromReport(string $uuid): static
{
$report = StudyReport::accession($uuid)->select(['id', 'study_id', 'file_path', 'created_at'])->firstOrFail();
$report = StudyReport::accession($uuid)->firstOrFail();
return static::make($report->study_id, $report);
}

View File

@ -25,4 +25,9 @@ public function signatureImagePath(): string
{
return Storage::disk('public')->path($this->user->radiologistProfile?->signature_image_path);
}
public function signatureImageUrl(): string
{
return Storage::disk('public')->url($this->user->radiologistProfile?->signature_image_path);
}
}

View File

@ -1,23 +1,24 @@
@extends('staff.reports.viewer.layout')
@section('content')
<header class="py-4">
<div class="container">
<div class="p-2 p-lg-2 bg-light rounded-3">
<div class="text-center">
<h6 class="text-muted">
{{ $report->study->modality }} Report
</h6>
<h3>
{{ $report->study->study_description }}
</h3>
</div>
</div>
</div>
</header>
<div class="container container-main">
<section class="pt-4" name="patient">
<div class="container">
@isset($notice)
<section class="pt-4" name="notice">
<div class="container-md px-md-3">
<div class="alert alert-warning" role="alert">
<h5 class="alert-heading d-flex align-items-center">
<span class="alert-icon rounded"><i
class="fa-solid fs-4 fa-circle-radiation me-2"></i></span>Notice
</h5>
<hr>
<p class="mb-0">{{ $notice }}</p>
</div>
</div>
</section>
@endisset
<section class="pt-4" name="patient">
<div class="mx-2">
<table class="table table-bordered border-gray">
<tr>
@ -42,14 +43,45 @@
</tr>
</table>
</div>
</div>
</section>
</section>
<section class="pt-4" name="report">
<div class="container px-lg-3">
<div class="border-dark mb-8">
{!! $report->getContent() !!}
<header class="py-2">
<div class="p-2 bg-light rounded-1">
<div class="text-center">
<h6 class="text-muted">
{{ $report->study->modality }} Report
</h6>
<h3>
{{ $report->study->study_description }}
</h3>
</div>
</div>
</div>
</section>
</header>
<section class="pt-4" name="report">
<div class="px-lg-3">
<div class="border-dark mb-8">
{!! $report->getContent() !!}
</div>
</div>
</section>
@isset($signature)
<section class="pt-4" name="signature">
<div class="px-lg-3">
<img src="{{ $signature }}">
</div>
</section>
@endisset
</div>
@endsection
@push('footer')
<footer class="footer">
<div class="container">
<span class="text-muted">
{{ config('app.name') }} &copy; {{ now()->year }} Dr. Masroor Ehsan
</span>
</div>
</footer>
@endpush

View File

@ -4,10 +4,14 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css"
integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg=="
crossorigin="anonymous" referrerpolicy="no-referrer"/>
<title>{{ $title }}</title>
<style>
body {
@ -15,19 +19,47 @@
width: 100%;
font-family: "Inter", serif;
font-optical-sizing: auto;
background: #edf1f5;
}
.container-main {
margin-top: 30px;
margin-bottom: 10px;
padding: 8px 8px 30px 8px;
background: #fff;
border: 1px solid #d3cfcf;
border-radius: 8px;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
-webkit-box-shadow: 0 0 14px rgba(0, 0, 0, .1);
-moz-box-shadow: 0 0 14px rgba(0, 0, 0, .1);
box-shadow: 0 0 14px rgba(0, 0, 0, .1);
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 40px;
line-height: 40px;
background-color: #f5f5f5;
}
.footer p, span {
text-align: center;
font-size: 12px;
}
</style>
@stack('header')
</head>
<body>
<nav class="navbar navbar-light bg-light">
<div class="container px-lg-2">
<span class="navbar-brand fw-semibold">{{ config('app.name') }}</span>
</div>
</nav>
<nav class="navbar navbar-light bg-light">
<div class="container px-lg-2">
<span class="navbar-brand fw-semibold">{{ config('app.name') }}</span>
</div>
</nav>
@yield('content')
@yield('content')
@stack('footer')
@stack('footer')
</body>
</html>

View File

@ -46,7 +46,7 @@ class TransformDoc
*/
public function __construct()
{
}
/**
@ -56,7 +56,7 @@ public function __construct()
*/
public function __destruct()
{
}
/**

View File

@ -50,7 +50,7 @@ abstract public function transformDocument($source, $target, $options = array())
/**
* Check if the extension if supproted
*
*
* @param string $fileExtension
* @param array $supportedExtensions
* @return array files extensions

View File

@ -777,12 +777,12 @@ protected function addDefaultStyles()
if ($docDefaultsStylesPpr) {
$css .= 'p, h1, h2, h3, h4, h5, h6, ul, ol {' . $this->addPprStyles($docDefaultsStylesPpr, true) . '}';
}
// addRprStyles
if ($docDefaultsStylesRpr) {
$css .= 'span {' . $this->addRprStyles($docDefaultsStylesRpr) . '}';
}
// default styles query by w:default="1"
$docDefaultsStyles = $xpathStyles->query('//w:style[@w:default="1"]');
foreach ($docDefaultsStyles as $docDefaultsStyle) {
@ -1110,7 +1110,7 @@ protected function getCellStyles($styles)
$cellStyles.= 'border-bottom: ' . $elementWTcBordersBottom->item(0)->getAttribute('w:sz') . ' ' . $borderStyle . ' #' . $elementWTcBordersBottom->item(0)->getAttribute('w:color') . ';';
$borderStylesCell .= 'border-bottom: ' . $elementWTcBordersBottom->item(0)->getAttribute('w:sz') . ' ' . $borderStyle . ' #' . $elementWTcBordersBottom->item(0)->getAttribute('w:color') . ';';
}
// left
$elementWTcBordersLeft = $elementWTcBorders->item(0)->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'left');
if ($elementWTcBordersLeft->length > 0) {
@ -1187,7 +1187,7 @@ protected function getNumberingLvlText($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumStart = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1197,7 +1197,7 @@ protected function getNumberingLvlText($id, $level)
return $elementAbstractNumStart->getAttribute('w:val');
}
// style not found, return 1 as default value
return '1';
}
@ -1226,7 +1226,7 @@ protected function getNumberingStart($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumStart = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1240,7 +1240,7 @@ protected function getNumberingStart($id, $level)
return '1';
}
}
// style not found, return 1 as default value
return '1';
}
@ -1277,7 +1277,7 @@ protected function getNumberingStyles($id, $level)
return $elementAbstractNumLvl;
}
// style not found
return null;
}
@ -1304,7 +1304,7 @@ protected function getNumberingType($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumFmt = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1314,7 +1314,7 @@ protected function getNumberingType($id, $level)
return $elementAbstractNumFmt->getAttribute('w:val');
}
// style not found
return null;
}
@ -1430,7 +1430,7 @@ protected function getTableStyles($styles)
$tableStyles.= 'border-bottom: ' . $this->htmlPlugin->transformSizes($elementWTblBordersBottom->item(0)->getAttribute('w:sz'), 'eights') . ' ' . $borderStyle . ' #' . $this->htmlPlugin->transformColors($elementWTblBordersBottom->item(0)->getAttribute('w:color')) . ';';
$borderStylesTable .= 'border-bottom: ' . $this->htmlPlugin->transformSizes($elementWTblBordersBottom->item(0)->getAttribute('w:sz'), 'eights') . ' ' . $borderStyle . ' #' . $this->htmlPlugin->transformColors($elementWTblBordersBottom->item(0)->getAttribute('w:color')) . ';';
}
// left
$elementWTblBordersLeft = $elementWTblBorders->item(0)->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'left');
if ($elementWTblBordersLeft->length > 0) {
@ -1668,7 +1668,7 @@ protected function getRelationshipContent($id)
} else {
$relsContent = $this->docxStructure->getContent('word/_rels/document.xml.rels');
}
$xmlDocumentRels = new \DOMDocument();
$xmlDocumentRels->loadXML($relsContent);
@ -1681,7 +1681,7 @@ protected function getRelationshipContent($id)
if (!$elementId || !$elementId->hasAttribute('Target')) {
return null;
}
return $elementId->getAttribute('Target');
}
@ -1919,7 +1919,7 @@ protected function transformW_DRAWING($childNode, $nodeClass)
$this->css[$nodeClass] .= 'display: inline;';
} else {
// anchor tag
// wrapSquare
$elementWrapSquare = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing', 'wrapSquare');
if ($elementWrapSquare->length > 0) {
@ -1993,12 +1993,12 @@ protected function transformW_ENDNOTEREFERENCE($childNode, $nodeClass)
$return = '';
$endnotesIndex = count($this->endnotesIndex) + 1;
while ($endnotesIndex > 0) {
while ($endnotesIndex > 0) {
foreach ($table as $rom => $arb) {
if ($endnotesIndex >= $arb) {
$endnotesIndex -= $arb;
$return .= $rom;
break;
if ($endnotesIndex >= $arb) {
$endnotesIndex -= $arb;
$return .= $rom;
break;
}
}
}
@ -2240,7 +2240,7 @@ protected function transformW_P($childNode, $nodeClass)
}
// handle tag
// default element
$elementTag = $this->htmlPlugin->getTag('paragraph');
@ -2253,7 +2253,7 @@ protected function transformW_P($childNode, $nodeClass)
// numbering tag
if (is_array($this->numberingParagraph)) {
// handle as p tags
// handle numbering in paragraph
$numPrTag = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'numPr');
// handle numbering in pStyle
@ -2295,7 +2295,7 @@ protected function transformW_P($childNode, $nodeClass)
$this->numberingParagraph['level'] = $numberingLevel;
$this->numberingParagraph['numId'] = $numIdTag->item(0)->getAttribute('w:val');
switch ($numberingStyle) {
case 'bullet':
// default value
@ -2303,7 +2303,7 @@ protected function transformW_P($childNode, $nodeClass)
if ($listLvlText == 'o') {
$this->prependTValue = '◦' . ' ';
}
break;
break;
case 'decimal':
// iterate numberLevel to handle level list when displaying sublevels such as 1.1. 1.2
for ($i = $numberingLevel; $i >= 0; $i--) {
@ -2517,7 +2517,7 @@ protected function transformW_P($childNode, $nodeClass)
}
}
}
// remove extra , and . before adding it to the HTML
$nodeClassHTML = str_replace(array(',', '.'), '', $nodeClass);
@ -2593,7 +2593,7 @@ protected function transformW_P($childNode, $nodeClass)
}
if ($closeNewList === true) {
unset($this->listStartValues[$numIdTag->item(0)->getAttribute('w:val')]);
for ($iClose = 0; $iClose < $iterationListClose; $iClose++) {
for ($iClose = 0; $iClose < $iterationListClose; $iClose++) {
$this->html .= '</'.$tagTypeList.'>';
}
}
@ -2659,7 +2659,7 @@ protected function transformW_R($childNode, $nodeClass)
$this->html = str_replace('{{ CLASS_COMPLEX_FIELD }}', $nodeClass, $this->html);
}
}
// remove extra , and . before adding it to the HTML
$nodeClassHTML = str_replace(array(',', '.'), '', $nodeClass);
@ -2841,7 +2841,7 @@ protected function transformW_TBL($childNode, $nodeClass)
}
}
// cells
// cells
$xpathDOMXPathWTblTrTc = new \DOMXPath($elementWTblTr->ownerDocument);
$xpathDOMXPathWTblTrTc->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$elementsWTblTrTc = $xpathDOMXPathWTblTrTc->query('w:tc|w:sdt', $elementWTblTr);
@ -2927,7 +2927,7 @@ protected function transformW_TBL($childNode, $nodeClass)
if (!empty($cellPadding)) {
$this->css[$nodeTdClass] .= $cellPadding;
}
// cell properties
$elementWTblTrTcTcpr = $elementWTblTrTc->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'tcPr');
if ($elementWTblTrTcTcpr->length > 0) {
@ -3060,16 +3060,16 @@ protected function transformIntegerToRoman($value) {
$table = array('m' => 1000, 'cm' => 900, 'd' => 500, 'cd' => 400, 'c' => 100, 'xc' => 90, 'l' => 50, 'xl' => 40, 'x' => 10, 'ix' => 9, 'v' => 5, 'iv' => 4, 'i' => 1);
$return = '';
while ($value > 0) {
while ($value > 0) {
foreach ($table as $rom => $arb) {
if ($value >= $arb) {
$value -= $arb;
$return .= $rom;
break;
if ($value >= $arb) {
$value -= $arb;
$return .= $rom;
break;
}
}
}
return $return;
}

View File

@ -235,7 +235,7 @@ public function transform(TransformDocAdvHTMLPlugin $htmlPlugin, $options = arra
$this->html = '';
}
$this->html = '';
$footersContents = $this->docxStructure->getContentByType('footers');
$this->target = 'footers';
foreach ($footersContents as $footerContent) {
@ -389,7 +389,7 @@ public function transform(TransformDocAdvHTMLPlugin $htmlPlugin, $options = arra
/**
* Iterate the contents and transform them
*
* @param
* @param
* @param array $options
* Values:
* 'javaScriptAtTop' => default as false. If true add JS in the head tag.
@ -738,7 +738,7 @@ protected function addRprStyles($node)
} else if ($rprStyle->hasAttribute('w:cs')) {
$fontFamily = $rprStyle->getAttribute('w:cs');
}
$styles .= 'font-family: "' . $fontFamily. '";';
break;
case 'w:shd':
@ -860,7 +860,7 @@ protected function addDefaultStyles()
if ($docDefaultsStylesPpr) {
$css .= 'p, h1, h2, h3, h4, h5, h6, ul, ol {' . $this->addPprStyles($docDefaultsStylesPpr) . '}';
}
// addRprStyles
if ($docDefaultsStylesRpr) {
$css .= 'span {' . $this->addRprStyles($docDefaultsStylesRpr) . '}';
@ -1033,7 +1033,7 @@ protected function getCellStyles($styles)
$cellStyles .= 'border-bottom: none;';
$borderStylesCell .= 'border-bottom: none;';
}
// left
$elementWTcBordersLeft = $elementWTcBorders->item(0)->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'left');
if ($elementWTcBordersLeft->length > 0) {
@ -1120,7 +1120,7 @@ protected function getNumberingLvlText($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumStart = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1130,7 +1130,7 @@ protected function getNumberingLvlText($id, $level)
return $elementAbstractNumStart->getAttribute('w:val');
}
// style not found, return 1 as default value
return '1';
}
@ -1159,7 +1159,7 @@ protected function getNumberingStart($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumStart = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1173,7 +1173,7 @@ protected function getNumberingStart($id, $level)
return '1';
}
}
// style not found, return 1 as default value
return '1';
}
@ -1212,7 +1212,7 @@ protected function getNumberingStyles($id, $level)
return $elementAbstractNumLvl;
}
// style not found
return null;
}
@ -1241,19 +1241,19 @@ protected function getNumberingType($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumFmt = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
'/w:lvl[@w:ilvl="' . $level . '"]' .
'/w:numFmt'
)->item(0);
if ($elementAbstractNumFmt != null) {
return $elementAbstractNumFmt->getAttribute('w:val');
}
}
// style not found
return null;
}
@ -1367,7 +1367,7 @@ protected function getTableStyles($styles)
$tableStyles.= 'border-bottom: ' . $this->htmlPlugin->transformSizes($elementWTblBordersBottom->item(0)->getAttribute('w:sz'), 'eights') . ' ' . $borderStyle . ' #' . $this->htmlPlugin->transformColors($elementWTblBordersBottom->item(0)->getAttribute('w:color')) . ';';
$borderStylesTable .= 'border-bottom: ' . $this->htmlPlugin->transformSizes($elementWTblBordersBottom->item(0)->getAttribute('w:sz'), 'eights') . ' ' . $borderStyle . ' #' . $this->htmlPlugin->transformColors($elementWTblBordersBottom->item(0)->getAttribute('w:color')) . ';';
}
// left
$elementWTblBordersLeft = $elementWTblBorders->item(0)->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'left');
if ($elementWTblBordersLeft->length > 0) {
@ -1606,7 +1606,7 @@ protected function getRelationshipContent($id)
} else {
$relsContent = $this->docxStructure->getContent('word/_rels/document.xml.rels');
}
$xmlDocumentRels = new \DOMDocument();
$optionEntityLoader = libxml_disable_entity_loader(true);
@ -1621,7 +1621,7 @@ protected function getRelationshipContent($id)
if (!$elementId || !$elementId->hasAttribute('Target')) {
return null;
}
return $elementId->getAttribute('Target');
}
@ -1931,7 +1931,7 @@ protected function transformW_DRAWING($childNode, $nodeClass)
$this->css[$nodeClass] .= 'display: inline;';
} else {
// anchor tag
// wrapSquare
$elementWrapSquare = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing', 'wrapSquare');
if ($elementWrapSquare->length > 0) {
@ -2014,7 +2014,7 @@ protected function transformW_DRAWING($childNode, $nodeClass)
<script>
chartDiv = document.getElementById("chart_'.$elementCChart->getAttribute('r:id').'");
Plotly.plot(
chartDiv,
chartDiv,
[{
values: ['.implode(',', $valuesValues).'],
labels: ['.implode(',', $labelsValues).'],
@ -2065,12 +2065,12 @@ protected function transformW_ENDNOTEREFERENCE($childNode, $nodeClass)
$return = '';
$endnotesIndex = count($this->endnotesIndex) + 1;
while ($endnotesIndex > 0) {
while ($endnotesIndex > 0) {
foreach ($table as $rom => $arb) {
if ($endnotesIndex >= $arb) {
$endnotesIndex -= $arb;
$return .= $rom;
break;
if ($endnotesIndex >= $arb) {
$endnotesIndex -= $arb;
$return .= $rom;
break;
}
}
}
@ -2322,7 +2322,7 @@ protected function transformW_P($childNode, $nodeClass)
}
// handle tag
// default element
$elementTag = $this->htmlPlugin->getTag('paragraph');
@ -2348,7 +2348,7 @@ protected function transformW_P($childNode, $nodeClass)
// numbering tag
if (is_array($this->numberingParagraph)) {
// handle as p tags
// handle numbering in paragraph
$numPrTag = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'numPr');
// handle numbering in pStyle
@ -2397,7 +2397,7 @@ protected function transformW_P($childNode, $nodeClass)
if ($listLvlText == 'o') {
$this->prependTValue = '◦' . ' ';
}
break;
break;
case 'decimal':
// iterate numberLevel to handle level list when displaying sublevels such as 1.1. 1.2
for ($i = $numberingLevel; $i >= 0; $i--) {
@ -2690,7 +2690,7 @@ protected function transformW_P($childNode, $nodeClass)
}
if ($closeNewList === true) {
unset($this->listStartValues[$numIdTag->item(0)->getAttribute('w:val')]);
for ($iClose = 0; $iClose < $iterationListClose; $iClose++) {
for ($iClose = 0; $iClose < $iterationListClose; $iClose++) {
$this->html .= '</'.$tagTypeList.'>';
}
}
@ -2964,13 +2964,13 @@ protected function transformW_SDT($childNode, $nodeClass)
case 'w:date';
// get text value from w:stdContent tag
$sdtContentNode = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'sdtContent')->item(0);
$this->html .= '<p><input type="date" placeholder="'.$sdtContentNode->textContent.'"></p>';
break;
default:
// get text value from w:stdContent tag
$sdtContentNode = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'sdtContent')->item(0);
$this->html .= '<span>'.$sdtContentNode->textContent.'</span>';
break;
}
@ -3068,7 +3068,7 @@ protected function transformW_TBL($childNode, $nodeClass)
}
}
// cells
// cells
$xpathDOMXPathWTblTrTc = new \DOMXPath($elementWTblTr->ownerDocument);
$xpathDOMXPathWTblTrTc->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$elementsWTblTrTc = $xpathDOMXPathWTblTrTc->query('w:tc|w:sdt', $elementWTblTr);
@ -3154,7 +3154,7 @@ protected function transformW_TBL($childNode, $nodeClass)
if (!empty($cellPadding)) {
$this->css[$nodeTdClass] .= $cellPadding;
}
// cell properties
$elementWTblTrTcTcpr = $elementWTblTrTc->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'tcPr');
if ($elementWTblTrTcTcpr->length > 0) {
@ -3277,7 +3277,7 @@ protected function transformW_TBL($childNode, $nodeClass)
* @param String $nodeClass
*/
protected function transformW_TAB($childNode, $nodeClass)
{
{
$this->html .= '<span class="tabcontent"></span>';
}
@ -3308,7 +3308,7 @@ protected function transformW_T($childNode, $nodeClass)
$nodeValue = $this->prependTValue . $nodeValue;
$this->prependTValue = null;
}
$this->html .= $nodeValue;
}
@ -3321,16 +3321,16 @@ protected function transformIntegerToRoman($value) {
$table = array('m' => 1000, 'cm' => 900, 'd' => 500, 'cd' => 400, 'c' => 100, 'xc' => 90, 'l' => 50, 'xl' => 40, 'x' => 10, 'ix' => 9, 'v' => 5, 'iv' => 4, 'i' => 1);
$return = '';
while ($value > 0) {
while ($value > 0) {
foreach ($table as $rom => $arb) {
if ($value >= $arb) {
$value -= $arb;
$return .= $rom;
break;
if ($value >= $arb) {
$value -= $arb;
$return .= $rom;
break;
}
}
}
return $return;
}

View File

@ -110,7 +110,7 @@ public function transformColors($color) {
public function transformSizes($value, $source, $target = null)
{
$returnValue = 0;
if ($target === null) {
$target = $this->unit;
}
@ -159,10 +159,10 @@ public function transformSizes($value, $source, $target = null)
}
}
}
// normalize decimal values to use dots
$returnValue = str_replace(',', '.', $returnValue);
return (string)$returnValue . $target;
}
}

View File

@ -109,7 +109,7 @@ public function transformColors($color) {
public function transformSizes($value, $source, $target = null)
{
$returnValue = 0;
if ($target === null) {
$target = $this->unit;
}
@ -158,10 +158,10 @@ public function transformSizes($value, $source, $target = null)
}
}
}
// normalize decimal values to use dots
$returnValue = str_replace(',', '.', $returnValue);
return (string)$returnValue . $target;
}
}

View File

@ -110,7 +110,7 @@ public function transformColors($color) {
public function transformSizes($value, $source, $target = null)
{
$returnValue = 0;
if ($target === null) {
$target = $this->unit;
}
@ -159,10 +159,10 @@ public function transformSizes($value, $source, $target = null)
}
}
}
// normalize decimal values to use dots
$returnValue = str_replace(',', '.', $returnValue);
return (string)$returnValue . $target;
}
}

View File

@ -25,7 +25,7 @@ class TransformDocAdvLibreOffice extends TransformDocAdv
{
/**
* Calculate and return the document statistics
*
*
* @param string $source DOCX document
* @return array
*/
@ -87,7 +87,7 @@ public function transformDocument($source, $target, $options = array())
$allowedExtensionsTarget = array('doc', 'docx', 'html', 'odt', 'pdf', 'png', 'rtf', 'txt', 'xhtml');
$filesExtensions = $this->checkSupportedExtension($source, $target, $allowedExtensionsSource, $allowedExtensionsTarget);
if (!isset($options['method'])) {
$options['method'] = 'direct';
}
@ -128,7 +128,7 @@ public function transformDocument($source, $target, $options = array())
}
}
// if the outdir option is set use it as target path, instead use the dir path
// if the outdir option is set use it as target path, instead use the dir path
if (isset($options['outdir'])) {
$outdir = $options['outdir'];
} else {

View File

@ -21,7 +21,7 @@ class TransformDocAdvMSWord extends TransformDocAdv
{
/**
* Calculate and return the document statistics
*
*
* @param string $source DOCX document
* @param array $options :
* 'selectedContent' (string) : documents or active (default)

View File

@ -119,14 +119,14 @@ public function replaceChartsWithImages($source){
$pictureFragment->appendXML($picture);
$domElementAGraphicData->appendChild($pictureFragment);
$sourceDocx->addFile($listChartImages[$indexImage], 'word/media/' . $listChartImages[$indexImage]);
//Modify the Type attribute of document.xml.rels to http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
//and the Target to media/'.$listChartImages[$indexImage]
$relsImage = $documentRelsDOM->xpath('//ns:Relationship[@Id="'. $relationshipChart[0]->attributes()->Id.'"]');
$relsImage[0]['Type'] = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image';
$relsImage[0]['Target'] = 'media/' . $listChartImages[$indexImage];
$indexImage++;
$indexImage++;
}
// save the modified document.xml.rels file
@ -135,11 +135,11 @@ public function replaceChartsWithImages($source){
$docXML = str_replace('<pic:pic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">', '<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">', $docXML);
$docXML = str_replace('<pic:pic xmlns:r="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"', '<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">', $docXML);
$sourceDocx->addFromString('word/document.xml', $docXML);
// save the modified document.xml.rels file
$relsDoc = $documentRelsDOM->asXML();
$sourceDocx->addFromString('word/_rels/document.xml.rels', $relsDoc);
// make sure that there is the associated content type "png"
$position = strpos('Extension="png"', $contentTypesXML);
if($position === false){
@ -155,72 +155,6 @@ public function replaceChartsWithImages($source){
}
}
/**
* To add support of sys_get_temp_dir for PHP versions under 5.2.1
*
* @access protected
* @return string
*/
protected function getTempDirPath()
{
if ($this->phpdocxconfig['settings']['temp_path']) {
return $this->phpdocxconfig['settings']['temp_path'];
}
if (!function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir()
{
if ($temp = getenv('TMP')) {
return $temp;
}
if ($temp = getenv('TEMP')) {
return $temp;
}
if ($temp = getenv('TMPDIR')) {
return $temp;
}
$temp = tempnam(__FILE__, '');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
} else {
return sys_get_temp_dir();
}
}
/**
*
*/
protected function getTemplateImage($name, $id)
{
$templateImage = '<pic:pic xmlns:r="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<pic:nvPicPr>
<pic:cNvPr id="0" name="' . $name .'"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="' . $id . '"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="4876800" cy="3657600"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>';
return $templateImage;
}
/**
* Transform all documents supported by OpenOffice
*
@ -246,7 +180,7 @@ public function transformDocument($source, $target, $options = array())
// get the file info
$sourceFileInfo = pathinfo($source);
$sourceExtension = $sourceFileInfo['extension'];
if (!isset($options['method'])) {
$options['method'] = 'direct';
}
@ -341,4 +275,70 @@ public function transformDocument($source, $target, $options = array())
}
}
/**
* To add support of sys_get_temp_dir for PHP versions under 5.2.1
*
* @access protected
* @return string
*/
protected function getTempDirPath()
{
if ($this->phpdocxconfig['settings']['temp_path']) {
return $this->phpdocxconfig['settings']['temp_path'];
}
if (!function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir()
{
if ($temp = getenv('TMP')) {
return $temp;
}
if ($temp = getenv('TEMP')) {
return $temp;
}
if ($temp = getenv('TMPDIR')) {
return $temp;
}
$temp = tempnam(__FILE__, '');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
} else {
return sys_get_temp_dir();
}
}
/**
*
*/
protected function getTemplateImage($name, $id)
{
$templateImage = '<pic:pic xmlns:r="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<pic:nvPicPr>
<pic:cNvPr id="0" name="' . $name .'"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="' . $id . '"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="4876800" cy="3657600"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>';
return $templateImage;
}
}

View File

@ -761,12 +761,12 @@ protected function addDefaultStyles()
if ($docDefaultsStylesPpr) {
$css .= 'p, h1, h2, h3, h4, h5, h6, ul, ol {' . $this->addPprStyles($docDefaultsStylesPpr, true) . '}';
}
// addRprStyles
if ($docDefaultsStylesRpr) {
$css .= 'span {' . $this->addRprStyles($docDefaultsStylesRpr) . '}';
}
// default styles query by w:default="1"
$docDefaultsStyles = $xpathStyles->query('//w:style[@w:default="1"]');
foreach ($docDefaultsStyles as $docDefaultsStyle) {
@ -1098,7 +1098,7 @@ protected function getCellStyles($styles)
$cellStyles.= 'border-bottom: ' . $elementWTcBordersBottom->item(0)->getAttribute('w:sz') . ' ' . $borderStyle . ' #' . $elementWTcBordersBottom->item(0)->getAttribute('w:color') . ';';
$borderStylesCell .= 'border-bottom: ' . $elementWTcBordersBottom->item(0)->getAttribute('w:sz') . ' ' . $borderStyle . ' #' . $elementWTcBordersBottom->item(0)->getAttribute('w:color') . ';';
}
// left
$elementWTcBordersLeft = $elementWTcBorders->item(0)->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'left');
if ($elementWTcBordersLeft->length > 0) {
@ -1166,7 +1166,7 @@ protected function getNumberingLvlText($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumStart = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1176,7 +1176,7 @@ protected function getNumberingLvlText($id, $level)
return $elementAbstractNumStart->getAttribute('w:val');
}
// style not found, return 1 as default value
return '1';
}
@ -1205,7 +1205,7 @@ protected function getNumberingStart($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumStart = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1219,7 +1219,7 @@ protected function getNumberingStart($id, $level)
return '1';
}
}
// style not found, return 1 as default value
return '1';
}
@ -1256,7 +1256,7 @@ protected function getNumberingStyles($id, $level)
return $elementAbstractNumLvl;
}
// style not found
return null;
}
@ -1283,7 +1283,7 @@ protected function getNumberingType($id, $level)
if ($elementNum != '') {
// get w:abstractNumId used to set the numbering styles
$abstractNumId = $elementNum->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'abstractNumId')->item(0)->getAttribute('w:val');
// get the style of the w:abstractNum related to w:abstractNumId
$elementAbstractNumFmt = $xpathNumbering->query(
'//w:abstractNum[@w:abstractNumId="' . $abstractNumId . '"]' .
@ -1293,7 +1293,7 @@ protected function getNumberingType($id, $level)
return $elementAbstractNumFmt->getAttribute('w:val');
}
// style not found
return null;
}
@ -1409,7 +1409,7 @@ protected function getTableStyles($styles)
$tableStyles.= 'border-bottom: ' . $this->htmlPlugin->transformSizes($elementWTblBordersBottom->item(0)->getAttribute('w:sz'), 'eights') . ' ' . $borderStyle . ' #' . $this->htmlPlugin->transformColors($elementWTblBordersBottom->item(0)->getAttribute('w:color')) . ';';
$borderStylesTable .= 'border-bottom: ' . $this->htmlPlugin->transformSizes($elementWTblBordersBottom->item(0)->getAttribute('w:sz'), 'eights') . ' ' . $borderStyle . ' #' . $this->htmlPlugin->transformColors($elementWTblBordersBottom->item(0)->getAttribute('w:color')) . ';';
}
// left
$elementWTblBordersLeft = $elementWTblBorders->item(0)->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'left');
if ($elementWTblBordersLeft->length > 0) {
@ -1647,7 +1647,7 @@ protected function getRelationshipContent($id)
} else {
$relsContent = $this->docxStructure->getContent('word/_rels/document.xml.rels');
}
$xmlDocumentRels = new \DOMDocument();
$xmlDocumentRels->loadXML($relsContent);
@ -1660,7 +1660,7 @@ protected function getRelationshipContent($id)
if (!$elementId || !$elementId->hasAttribute('Target')) {
return null;
}
return $elementId->getAttribute('Target');
}
@ -1924,12 +1924,12 @@ protected function transformW_ENDNOTEREFERENCE($childNode, $nodeClass)
$return = '';
$endnotesIndex = count($this->endnotesIndex) + 1;
while ($endnotesIndex > 0) {
while ($endnotesIndex > 0) {
foreach ($table as $rom => $arb) {
if ($endnotesIndex >= $arb) {
$endnotesIndex -= $arb;
$return .= $rom;
break;
if ($endnotesIndex >= $arb) {
$endnotesIndex -= $arb;
$return .= $rom;
break;
}
}
}
@ -2171,7 +2171,7 @@ protected function transformW_P($childNode, $nodeClass)
}
// handle tag
// default element
$elementTag = $this->htmlPlugin->getTag('paragraph');
@ -2184,7 +2184,7 @@ protected function transformW_P($childNode, $nodeClass)
// numbering tag
if (is_array($this->numberingParagraph)) {
// handle as p tags
// handle numbering in paragraph
$numPrTag = $childNode->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'numPr');
// handle numbering in pStyle
@ -2226,7 +2226,7 @@ protected function transformW_P($childNode, $nodeClass)
$this->numberingParagraph['level'] = $numberingLevel;
$this->numberingParagraph['numId'] = $numIdTag->item(0)->getAttribute('w:val');
switch ($numberingStyle) {
case 'bullet':
// default value
@ -2234,7 +2234,7 @@ protected function transformW_P($childNode, $nodeClass)
if ($listLvlText == 'o') {
$this->prependTValue = '◦' . ' ';
}
break;
break;
case 'decimal':
// iterate numberLevel to handle level list when displaying sublevels such as 1.1. 1.2
for ($i = $numberingLevel; $i >= 0; $i--) {
@ -2448,7 +2448,7 @@ protected function transformW_P($childNode, $nodeClass)
}
}
}
// remove extra , and . before adding it to the HTML
$nodeClassHTML = str_replace(array(',', '.'), '', $nodeClass);
@ -2524,7 +2524,7 @@ protected function transformW_P($childNode, $nodeClass)
}
if ($closeNewList === true) {
unset($this->listStartValues[$numIdTag->item(0)->getAttribute('w:val')]);
for ($iClose = 0; $iClose < $iterationListClose; $iClose++) {
for ($iClose = 0; $iClose < $iterationListClose; $iClose++) {
$this->html .= '</'.$tagTypeList.'>';
}
}
@ -2590,7 +2590,7 @@ protected function transformW_R($childNode, $nodeClass)
$this->html = str_replace('{{ CLASS_COMPLEX_FIELD }}', $nodeClass, $this->html);
}
}
// remove extra , and . before adding it to the HTML
$nodeClassHTML = str_replace(array(',', '.'), '', $nodeClass);
@ -2772,7 +2772,7 @@ protected function transformW_TBL($childNode, $nodeClass)
}
}
// cells
// cells
$xpathDOMXPathWTblTrTc = new \DOMXPath($elementWTblTr->ownerDocument);
$xpathDOMXPathWTblTrTc->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$elementsWTblTrTc = $xpathDOMXPathWTblTrTc->query('w:tc|w:sdt', $elementWTblTr);
@ -2858,7 +2858,7 @@ protected function transformW_TBL($childNode, $nodeClass)
if (!empty($cellPadding)) {
$this->css[$nodeTdClass] .= $cellPadding;
}
// cell properties
$elementWTblTrTcTcpr = $elementWTblTrTc->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'tcPr');
if ($elementWTblTrTcTcpr->length > 0) {
@ -2991,16 +2991,16 @@ protected function transformIntegerToRoman($value) {
$table = array('m' => 1000, 'cm' => 900, 'd' => 500, 'cd' => 400, 'c' => 100, 'xc' => 90, 'l' => 50, 'xl' => 40, 'x' => 10, 'ix' => 9, 'v' => 5, 'iv' => 4, 'i' => 1);
$return = '';
while ($value > 0) {
while ($value > 0) {
foreach ($table as $rom => $arb) {
if ($value >= $arb) {
$value -= $arb;
$return .= $rom;
break;
if ($value >= $arb) {
$value -= $arb;
$return .= $rom;
break;
}
}
}
return $return;
}