Skip to content

Commit 9770f44

Browse files
author
Roman Syroeshko
committed
Shortened names of TemplateProcessor properties.
1 parent 6ef9ac2 commit 9770f44

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,28 @@ class TemplateProcessor
3535
/**
3636
* @var string Temporary document filename (with path).
3737
*/
38-
protected $temporaryDocumentFilename;
38+
protected $tempDocumentFilename;
3939

4040
/**
4141
* Content of main document part (in XML format) of the temporary document.
4242
*
4343
* @var string
4444
*/
45-
protected $temporaryDocumentMainPart;
45+
protected $tempDocumentMainPart;
4646

4747
/**
4848
* Content of headers (in XML format) of the temporary document.
4949
*
5050
* @var string[]
5151
*/
52-
protected $temporaryDocumentHeaders = array();
52+
protected $tempDocumentHeaders = array();
5353

5454
/**
5555
* Content of footers (in XML format) of the temporary document.
5656
*
5757
* @var string[]
5858
*/
59-
protected $temporaryDocumentFooters = array();
59+
protected $tempDocumentFooters = array();
6060

6161
/**
6262
* @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception.
@@ -68,34 +68,34 @@ class TemplateProcessor
6868
public function __construct($documentTemplate)
6969
{
7070
// Temporary document filename initialization
71-
$this->temporaryDocumentFilename = tempnam(Settings::getTempDir(), 'PhpWord');
72-
if (false === $this->temporaryDocumentFilename) {
71+
$this->tempDocumentFilename = tempnam(Settings::getTempDir(), 'PhpWord');
72+
if (false === $this->tempDocumentFilename) {
7373
throw new CreateTemporaryFileException();
7474
}
7575

7676
// Template file cloning
77-
if (false === copy($documentTemplate, $this->temporaryDocumentFilename)) {
78-
throw new CopyFileException($documentTemplate, $this->temporaryDocumentFilename);
77+
if (false === copy($documentTemplate, $this->tempDocumentFilename)) {
78+
throw new CopyFileException($documentTemplate, $this->tempDocumentFilename);
7979
}
8080

8181
// Temporary document content extraction
8282
$this->zipClass = new ZipArchive();
83-
$this->zipClass->open($this->temporaryDocumentFilename);
83+
$this->zipClass->open($this->tempDocumentFilename);
8484
$index = 1;
8585
while (false !== $this->zipClass->locateName($this->getHeaderName($index))) {
86-
$this->temporaryDocumentHeaders[$index] = $this->fixBrokenMacros(
86+
$this->tempDocumentHeaders[$index] = $this->fixBrokenMacros(
8787
$this->zipClass->getFromName($this->getHeaderName($index))
8888
);
8989
$index++;
9090
}
9191
$index = 1;
9292
while (false !== $this->zipClass->locateName($this->getFooterName($index))) {
93-
$this->temporaryDocumentFooters[$index] = $this->fixBrokenMacros(
93+
$this->tempDocumentFooters[$index] = $this->fixBrokenMacros(
9494
$this->zipClass->getFromName($this->getFooterName($index))
9595
);
9696
$index++;
9797
}
98-
$this->temporaryDocumentMainPart = $this->fixBrokenMacros($this->zipClass->getFromName('word/document.xml'));
98+
$this->tempDocumentMainPart = $this->fixBrokenMacros($this->zipClass->getFromName('word/document.xml'));
9999
}
100100

101101
/**
@@ -118,7 +118,7 @@ public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslO
118118
}
119119

120120
$xmlDOMDocument = new \DOMDocument();
121-
if (false === $xmlDOMDocument->loadXML($this->temporaryDocumentMainPart)) {
121+
if (false === $xmlDOMDocument->loadXML($this->tempDocumentMainPart)) {
122122
throw new Exception('Could not load XML from the given template.');
123123
}
124124

@@ -127,7 +127,7 @@ public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslO
127127
throw new Exception('Could not transform the given XML document.');
128128
}
129129

130-
$this->temporaryDocumentMainPart = $xmlTransformed;
130+
$this->tempDocumentMainPart = $xmlTransformed;
131131
}
132132

133133
/**
@@ -138,14 +138,14 @@ public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslO
138138
*/
139139
public function setValue($search, $replace, $limit = -1)
140140
{
141-
foreach ($this->temporaryDocumentHeaders as $index => $headerXML) {
142-
$this->temporaryDocumentHeaders[$index] = $this->setValueForPart($this->temporaryDocumentHeaders[$index], $search, $replace, $limit);
141+
foreach ($this->tempDocumentHeaders as $index => $headerXML) {
142+
$this->tempDocumentHeaders[$index] = $this->setValueForPart($this->tempDocumentHeaders[$index], $search, $replace, $limit);
143143
}
144144

145-
$this->temporaryDocumentMainPart = $this->setValueForPart($this->temporaryDocumentMainPart, $search, $replace, $limit);
145+
$this->tempDocumentMainPart = $this->setValueForPart($this->tempDocumentMainPart, $search, $replace, $limit);
146146

147-
foreach ($this->temporaryDocumentFooters as $index => $headerXML) {
148-
$this->temporaryDocumentFooters[$index] = $this->setValueForPart($this->temporaryDocumentFooters[$index], $search, $replace, $limit);
147+
foreach ($this->tempDocumentFooters as $index => $headerXML) {
148+
$this->tempDocumentFooters[$index] = $this->setValueForPart($this->tempDocumentFooters[$index], $search, $replace, $limit);
149149
}
150150
}
151151

@@ -156,13 +156,13 @@ public function setValue($search, $replace, $limit = -1)
156156
*/
157157
public function getVariables()
158158
{
159-
$variables = $this->getVariablesForPart($this->temporaryDocumentMainPart);
159+
$variables = $this->getVariablesForPart($this->tempDocumentMainPart);
160160

161-
foreach ($this->temporaryDocumentHeaders as $headerXML) {
161+
foreach ($this->tempDocumentHeaders as $headerXML) {
162162
$variables = array_merge($variables, $this->getVariablesForPart($headerXML));
163163
}
164164

165-
foreach ($this->temporaryDocumentFooters as $footerXML) {
165+
foreach ($this->tempDocumentFooters as $footerXML) {
166166
$variables = array_merge($variables, $this->getVariablesForPart($footerXML));
167167
}
168168

@@ -183,7 +183,7 @@ public function cloneRow($search, $numberOfClones)
183183
$search = '${' . $search . '}';
184184
}
185185

186-
$tagPos = strpos($this->temporaryDocumentMainPart, $search);
186+
$tagPos = strpos($this->tempDocumentMainPart, $search);
187187
if (!$tagPos) {
188188
throw new Exception("Can not clone row, template variable not found or variable contains markup.");
189189
}
@@ -223,7 +223,7 @@ public function cloneRow($search, $numberOfClones)
223223
}
224224
$result .= $this->getSlice($rowEnd);
225225

226-
$this->temporaryDocumentMainPart = $result;
226+
$this->tempDocumentMainPart = $result;
227227
}
228228

229229
/**
@@ -239,7 +239,7 @@ public function cloneBlock($blockname, $clones = 1, $replace = true)
239239
$xmlBlock = null;
240240
preg_match(
241241
'/(<\?xml.*)(<w:p.*>\${' . $blockname . '}<\/w:.*?p>)(.*)(<w:p.*\${\/' . $blockname . '}<\/w:.*?p>)/is',
242-
$this->temporaryDocumentMainPart,
242+
$this->tempDocumentMainPart,
243243
$matches
244244
);
245245

@@ -251,10 +251,10 @@ public function cloneBlock($blockname, $clones = 1, $replace = true)
251251
}
252252

253253
if ($replace) {
254-
$this->temporaryDocumentMainPart = str_replace(
254+
$this->tempDocumentMainPart = str_replace(
255255
$matches[2] . $matches[3] . $matches[4],
256256
implode('', $cloned),
257-
$this->temporaryDocumentMainPart
257+
$this->tempDocumentMainPart
258258
);
259259
}
260260
}
@@ -273,15 +273,15 @@ public function replaceBlock($blockname, $replacement)
273273
{
274274
preg_match(
275275
'/(<\?xml.*)(<w:p.*>\${' . $blockname . '}<\/w:.*?p>)(.*)(<w:p.*\${\/' . $blockname . '}<\/w:.*?p>)/is',
276-
$this->temporaryDocumentMainPart,
276+
$this->tempDocumentMainPart,
277277
$matches
278278
);
279279

280280
if (isset($matches[3])) {
281-
$this->temporaryDocumentMainPart = str_replace(
281+
$this->tempDocumentMainPart = str_replace(
282282
$matches[2] . $matches[3] . $matches[4],
283283
$replacement,
284-
$this->temporaryDocumentMainPart
284+
$this->tempDocumentMainPart
285285
);
286286
}
287287
}
@@ -305,22 +305,22 @@ public function deleteBlock($blockname)
305305
*/
306306
public function save()
307307
{
308-
foreach ($this->temporaryDocumentHeaders as $index => $headerXML) {
309-
$this->zipClass->addFromString($this->getHeaderName($index), $this->temporaryDocumentHeaders[$index]);
308+
foreach ($this->tempDocumentHeaders as $index => $headerXML) {
309+
$this->zipClass->addFromString($this->getHeaderName($index), $this->tempDocumentHeaders[$index]);
310310
}
311311

312-
$this->zipClass->addFromString('word/document.xml', $this->temporaryDocumentMainPart);
312+
$this->zipClass->addFromString('word/document.xml', $this->tempDocumentMainPart);
313313

314-
foreach ($this->temporaryDocumentFooters as $index => $headerXML) {
315-
$this->zipClass->addFromString($this->getFooterName($index), $this->temporaryDocumentFooters[$index]);
314+
foreach ($this->tempDocumentFooters as $index => $headerXML) {
315+
$this->zipClass->addFromString($this->getFooterName($index), $this->tempDocumentFooters[$index]);
316316
}
317317

318318
// Close zip file
319319
if (false === $this->zipClass->close()) {
320320
throw new Exception('Could not close zip file.');
321321
}
322322

323-
return $this->temporaryDocumentFilename;
323+
return $this->tempDocumentFilename;
324324
}
325325

326326
/**
@@ -435,10 +435,10 @@ protected function getHeaderName($index)
435435
*/
436436
protected function findRowStart($offset)
437437
{
438-
$rowStart = strrpos($this->temporaryDocumentMainPart, '<w:tr ', ((strlen($this->temporaryDocumentMainPart) - $offset) * -1));
438+
$rowStart = strrpos($this->tempDocumentMainPart, '<w:tr ', ((strlen($this->tempDocumentMainPart) - $offset) * -1));
439439

440440
if (!$rowStart) {
441-
$rowStart = strrpos($this->temporaryDocumentMainPart, '<w:tr>', ((strlen($this->temporaryDocumentMainPart) - $offset) * -1));
441+
$rowStart = strrpos($this->tempDocumentMainPart, '<w:tr>', ((strlen($this->tempDocumentMainPart) - $offset) * -1));
442442
}
443443
if (!$rowStart) {
444444
throw new Exception('Can not find the start position of the row to clone.');
@@ -455,7 +455,7 @@ protected function findRowStart($offset)
455455
*/
456456
protected function findRowEnd($offset)
457457
{
458-
return strpos($this->temporaryDocumentMainPart, '</w:tr>', $offset) + 7;
458+
return strpos($this->tempDocumentMainPart, '</w:tr>', $offset) + 7;
459459
}
460460

461461
/**
@@ -468,9 +468,9 @@ protected function findRowEnd($offset)
468468
protected function getSlice($startPosition, $endPosition = 0)
469469
{
470470
if (!$endPosition) {
471-
$endPosition = strlen($this->temporaryDocumentMainPart);
471+
$endPosition = strlen($this->tempDocumentMainPart);
472472
}
473473

474-
return substr($this->temporaryDocumentMainPart, $startPosition, ($endPosition - $startPosition));
474+
return substr($this->tempDocumentMainPart, $startPosition, ($endPosition - $startPosition));
475475
}
476476
}

0 commit comments

Comments
 (0)