openofficeValidation.php
2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
class openofficeValidation extends serviceValidation {
/**
* Path to open office executable
*
* @author KnowledgeTree Team
* @access protected
* @var string
*/
public $soffice;
/**
* Flag if open office already provided
*
* @author KnowledgeTree Team
* @access private
* @var mixed
*/
public $providedOpenOffice = false;
/**
* Flag, if open office is specified and an error has been encountered
*
* @author KnowledgeTree Team
* @access public
* @var boolean
*/
private $openOfficeExeError = false;
/**
* Holds path error, if open office is specified
*
* @author KnowledgeTree Team
* @access public
* @var string
*/
private $openOfficeExeMessage = '';
/**
* Open Office Installed
*
* @author KnowledgeTree Team
* @access private
* @var mixed
*/
private $openOfficeCheck = 'cross';
/**
* Open Office windows locations
*
* @author KnowledgeTree Team
* @access private
* @var mixed
*/
private $windowsLocations = array("C:\Program Files\OpenOffice.org 3\program", "C:\OpenOffice.org 3\program");
/**
* Open Office unix locations
*
* @author KnowledgeTree Team
* @access private
* @var mixed
*/
private $unixLocations = array("/usr/local/bin", "/usr/bin");
public function preset($options = null) {
$this->specifyOpenOffice();
}
/**
* Set template view to specify open office
*
* @author KnowledgeTree Team
* @param none
* @access private
* @return boolean
*/
private function specifyOpenOffice() {
$this->openOfficeExeError = true;
}
private function openOfficeInstalled() {
$this->openOfficeExeError = false;
}
public function getBinary() {
$this->soffice = $this->util->getOpenOffice();
}
public function binaryChecks() {
if($this->util->openOfficeSpecified()) {
$this->soffice = $this->util->openOfficeSpecified();
if(file_exists($this->soffice))
return $this->soffice;
else
return false;
} else {
$auto = $this->detectOpenOffice();
if($auto) {
$this->soffice = $auto;
return $this->soffice;
}
return false;
}
}
private function detectOpenOffice() {
if(WINDOWS_OS) {
$locations = $this->windowsLocations;
$bin = "soffice.exe";
} else {
$locations = $this->unixLocations;
$bin = "soffice";
}
foreach ($locations as $loc) {
$pathToBinary = $loc.DS.$bin;
if(file_exists($pathToBinary)) {
return $pathToBinary;
}
}
return false;
}
/**
* Set all silent mode varibles
*
* @author KnowledgeTree Team
* @param none
* @access private
* @return void
*/
public function storeSilent() {
$this->temp_variables['openOfficeInstalled'] = $this->installed;
$this->temp_variables['openOfficeExe'] = $this->soffice;
$this->temp_variables['openOfficeExeError'] = $this->openOfficeExeError;
$this->temp_variables['openOfficeExeMessage'] = $this->openOfficeExeMessage;
return $this->temp_variables;
}
}
?>