summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
diff options
context:
space:
mode:
authorDirk Riestere2017-03-20 21:38:22 +0100
committerDirk Riestere2017-03-20 21:38:22 +0100
commit574f9b1421f1c30ecc2459286bf8edd20c41f822 (patch)
tree90e993cef491bd0befda5917bdc629d6e9624f55 /modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
parentfrontend: -calendar scrolls to actual time, if space is to small to show full... (diff)
downloadslx-admin-574f9b1421f1c30ecc2459286bf8edd20c41f822.tar.gz
slx-admin-574f9b1421f1c30ecc2459286bf8edd20c41f822.tar.xz
slx-admin-574f9b1421f1c30ecc2459286bf8edd20c41f822.zip
XML parser ist implementiert und HisInOne kann jetzt gelesen werden
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php')
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index e857a26b..85d834ff 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -20,7 +20,7 @@ class Coursebackend_Davinci extends CourseBackend
public function checkConnection()
{
if ($this->location != "") {
- $this->fetchArray('B206');
+ $this->fetchSchedulesInternal(['B206']);
return !$this->error;
}
$this->error = true;
@@ -49,21 +49,28 @@ class Coursebackend_Davinci extends CourseBackend
return 0;
}
+ /**
+ * @param $response xml document
+ * @return bool|array array representation of the xml if possible
+ */
private function toArray($response)
{
-
try {
$cleanresponse = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
$xml = new SimpleXMLElement($cleanresponse);
$array = json_decode(json_encode((array)$xml), true);
} catch (Exception $exception) {
$this->error = true;
- $this->errormsg = "url did not send a xml";
+ $this->errormsg = "url did not answer with a xml, maybe the url is wrong or the room is wrong";
$array = false;
}
return $array;
}
+ /**
+ * @param $roomId string name of the room
+ * @return array|bool if successful the arrayrepresentation of the timetable
+ */
private function fetchArray($roomId)
{
$startDate = new DateTime('monday this week');
@@ -97,18 +104,17 @@ class Coursebackend_Davinci extends CourseBackend
public function fetchSchedulesInternal($roomIds)
{
$schedules = [];
-
foreach ($roomIds as $sroomId) {
$return = $this->fetchArray($sroomId);
if ($return === false) {
return false;
- } elseif (!isset($return['Lessons']['Lesson'])) {
+ }
+ $lessons = $this->getAttributes($return,'Lessons/Lesson');
+ if (!$lessons) {
$this->error = true;
$this->errormsg = "url send a xml in a wrong format";
return false;
}
- $lessons = $return['Lessons']['Lesson'];
-
$timetable = [];
foreach ($lessons as $lesson) {
$date = $lesson['Date'];
@@ -127,6 +133,7 @@ class Coursebackend_Davinci extends CourseBackend
}
$schedules[$sroomId] = $timetable;
}
+ error_log('123'.json_encode($schedules));
return $schedules;
}
}