ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BaseWriter.php
Go to the documentation of this file.
1<?php
2
4
5abstract class BaseWriter implements IWriter
6{
13 protected $includeCharts = false;
14
22 protected $preCalculateFormulas = true;
23
29 private $useDiskCaching = false;
30
36 private $diskCachingDirectory = './';
37
41 protected $fileHandle;
42
47
48 public function getIncludeCharts()
49 {
51 }
52
53 public function setIncludeCharts($pValue)
54 {
55 $this->includeCharts = (bool) $pValue;
56
57 return $this;
58 }
59
60 public function getPreCalculateFormulas()
61 {
63 }
64
65 public function setPreCalculateFormulas($pValue)
66 {
67 $this->preCalculateFormulas = (bool) $pValue;
68
69 return $this;
70 }
71
72 public function getUseDiskCaching()
73 {
75 }
76
77 public function setUseDiskCaching($pValue, $pDirectory = null)
78 {
79 $this->useDiskCaching = $pValue;
80
81 if ($pDirectory !== null) {
82 if (is_dir($pDirectory)) {
83 $this->diskCachingDirectory = $pDirectory;
84 } else {
85 throw new Exception("Directory does not exist: $pDirectory");
86 }
87 }
88
89 return $this;
90 }
91
92 public function getDiskCachingDirectory()
93 {
95 }
96
102 public function openFileHandle($filename): void
103 {
104 if (is_resource($filename)) {
105 $this->fileHandle = $filename;
106 $this->shouldCloseFile = false;
107
108 return;
109 }
110
111 $fileHandle = $filename ? fopen($filename, 'wb+') : false;
112 if ($fileHandle === false) {
113 throw new Exception('Could not open file "' . $filename . '" for writing.');
114 }
115
116 $this->fileHandle = $fileHandle;
117 $this->shouldCloseFile = true;
118 }
119
123 protected function maybeCloseFileHandle(): void
124 {
125 if ($this->shouldCloseFile) {
126 if (!fclose($this->fileHandle)) {
127 throw new Exception('Could not close file after writing.');
128 }
129 }
130 }
131}
$filename
Definition: buildRTE.php:89
An exception for terminatinating execution or to throw for unit testing.
getPreCalculateFormulas()
Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all f...
Definition: BaseWriter.php:60
setUseDiskCaching($pValue, $pDirectory=null)
Set use disk caching where possible?
Definition: BaseWriter.php:77
getDiskCachingDirectory()
Get disk caching directory.
Definition: BaseWriter.php:92
getIncludeCharts()
Write charts in workbook? If this is true, then the Writer will write definitions for any charts that...
Definition: BaseWriter.php:48
setPreCalculateFormulas($pValue)
Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae o...
Definition: BaseWriter.php:65
openFileHandle($filename)
Open file handle.
Definition: BaseWriter.php:102
getUseDiskCaching()
Get use disk caching where possible?
Definition: BaseWriter.php:72
setIncludeCharts($pValue)
Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in th...
Definition: BaseWriter.php:53
maybeCloseFileHandle()
Close file handle only if we opened it ourselves.
Definition: BaseWriter.php:123