class_LospService.inc.php
6.71 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
/**
* @file LospService.inc.php
* @category freeSN
* @mailto code [at] netz.coop
* @version 0.4.200901
* @link http://netz.coop
*
* @copyright Copyright by netz.coop e.G. 2015
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
class LospService extends aServiceStorable {
// public function &getBasisElementAddonDataBase($param_BEAName) {
// return false;
// }
/**
* @var array of the BasisElementAddonDataBase
*/
private static $BasisElementAddonDataBaseArray = array();
/**
* return the BasisElementAddonDataBase object
*/
public function &getBasisElementAddonDataBase($param_BEAName) {
if(class_exists($param_BEAName.'BEAS')) {
if(!array_key_exists($param_BEAName, self::$BasisElementAddonDataBaseArray) || !is_object(self::$BasisElementAddonDataBaseArray[$param_BEAName])) {
$BEADBName = $param_BEAName.'BEAS';
self::$BasisElementAddonDataBaseArray[$param_BEAName] = new $BEADBName();
}
return self::$BasisElementAddonDataBaseArray[$param_BEAName];
} else {
return false;
}
}
public function &loadObject(&$param_Object, Account &$param_HostAccount=null, $param_Parameter=null) {
if(is_subclass_of($param_Object, 'iBasisElement') && $param_Object->getObjVar('ID')) {
$param_Object = &$this->getBasisElement($param_Object->getObjVar('ID'), $param_BasisClipboard=null);
} else if(is_subclass_of($param_Object, 'BasisClipboard')) {
if($param_Object->getObjVar('CategoryName')) {
$var_BasisClipbaordName = get_class($param_Object).'::'.$param_Object->getObjVar('CategoryName');
} else {
$var_BasisClipbaordName = get_class($param_Object);
}
$var_PartOfBE = &$this->getBasisElement($param_Object->getObjVar('PartOfID'), array($var_BasisClipbaordName => true),$param_Object->getObjVar('ConditionArray'));
if(is_object($var_PartOfBE)) {
$var_BasisClipboard =&$var_PartOfBE->getClipboard($param_HostAccount, $this, $var_BasisClipbaordName);
if(is_subclass_of($var_BasisClipboard, 'BasisClipboard')) {
$var_BasisClipboard->setObjVar('PartOf', $var_PartOfBE);
$var_BasisClipboard->setObjVar('PartOfID', $var_PartOfBE->getObjVar('ID'));
$param_Object =&$var_BasisClipboard;
// D::backtrace();
// D::show($param_Object, $var_BasisClipboard);
} else {
D::li('LospService: laden von '.$param_Object.' fehlgeschlagen');
return false;
}
} else {
D::li('LospService ist noch nicht für '.$param_Object.' implementiert');
return false;
}
} else {
// D::li('LospService ist noch nicht für '.$param_Object.' implementiert');
return false;
}
return $param_Object;
}
public function saveObject( &$param_Object, Account &$param_HostAccount=null) {
}
private $cURLTools;
private $bool_Login = false;
public function __construct(array $param_Data, PDO $param_PDO=null) {
parent::__construct( $param_Data, $param_PDO);
$this->cURLTools = new cURLTools('Temp/cookie.txt');
}
public function connect() {
if($this->ConnectionData['user'] && $this->ConnectionData['passwd'] && $this->ConnectionData['host']) {
$this->cURLTools->curlLogin($this->ConnectionData['user'],$this->ConnectionData['passwd'],$this->ConnectionData['user'],null,$this->ConnectionData['host']);
} else {
D::li('anonym');
return false;
}
}
public function disconnect() {
if($this->bool_Login) {
$this->cURLTools->curlLogout();
$this->bool_Login = false;
}
}
// public function getBasisClipboard() {
//
// }
public function &getBasisElement($param_ID, array $param_BasisClipboardArray=null, array $param_ConditionArray = null, $param_GET = null) {
// $this->connect();
$param_host = $this->getConnectionData('host');
if($param_host && is_numeric($param_ID)) {
// if($param_GET) {
// D::show($param_GET, '$param_GET');
// }
$var_uri = LinkGenerator::getServiceLinkString('xml', $param_ID, $param_BasisClipboardArray, $param_ConditionArray, $param_GET);
$param_host .= '/service.php';
//D::backtrace($var_uri);
//D::show($param_BasisClipboardArray);
}
/**
* @param string|| array GET
* @param array POST,
* @param string $var_website
*/
//D::li(date("H:i:s"). " this->cURLTools->curlReceive(); $param_host <b>$var_uri</b>");
// D::show($param_BasisClipboardArray);
$string_return = $this->cURLTools->curlReceive($var_uri,null,$param_host);
if($string_return) {
$var_SimpleXMLElement = simplexml_load_string(trim($string_return));
if(get_class($var_SimpleXMLElement)=='SimpleXMLElement') {
$result = $var_SimpleXMLElement->xpath('/content/BasisElement');
if(!empty($result)) {
$var_attr = $result[0]->attributes();
$var_classname = (string) $var_attr['class'];
$var_BEobj =& MultimediaText::getFromMTextArray($var_attr['ID']) ;
//D::ulli($var_attr['ID'].' +++++++ '.$var_BEobj);
if($var_BEobj===false) {
// $var_BEobj = new $var_classname($this, $var_attr['ID']);
$var_BEobj = BasisElement::createNewInstance($this, $var_classname, $var_attr['ID']);
}
$var_BEobj->import($result[0]);
//$ClipboardArray = $var_BEobj->getObjVar('ClipboardArray');
//if($ClipboardArray['ThreadMessageBC::Blog']) {
// $var_addonArray = $ClipboardArray['ThreadMessageBC::Blog']->getObjVar('AddonManager')->getObjVar('AddonArray');
// D::li('5. '.$var_addonArray['Category']);
//}
return $var_BEobj;
} else {
// D::show($var_SimpleXMLElement, '$var_SimpleXMLElement');
return false;
}
} else {
D::li('FEHLER: konnte Objekt nicht fernladen');
D::ulli('$string_return('.$string_return.')');
return false;
}
} else {
D::li('FEHLER: konnte xml Objekt nicht fernladen');
D::ulli($param_host.''.$var_uri);
return false;
}
// $this->disconnect();
}
public function __deconstruct() {
}
/**
* @todo function not implemented for LospService
*/
public function BC_getStates() {
return false;
}
/**
* @todo function not implemented for LospService
*/
public function Profile_IDToNickName($ProfileID) {
return $ProfileID;
}
public function getAllBasisElementIDsForBasisClipboard(){
return array();
}
}
?>