/** * Get info from each persons calendar * @return CalendarDates $calendarDates */ public function getCalendarInfo() { //get URL to calendar page $url = $this->calendarLink; //Get the sourcecode $data = $this->curl->curlGetReq($url); //find all links to each person $query = "//a"; $aTagNodes = $this->curl->getDOMData($data, $query); $calendarDates = new CalendarDateRepository(); //loop through each link, representing a person foreach ($aTagNodes as $at) { //get the href to that persons calendar $calURL = $at->getAttribute("href"); //get the sourcecode of that page $data = $this->curl->curlGetReq($url . $calURL); //get the table header containing name of the days $query = "//th"; $days = $this->curl->getDOMData($data, $query); //get the table data containing availability $query = "//td"; $availibility = $this->curl->getDOMData($data, $query); $dates = array(); /* * loop table data, if the availability of that day is ok * save that data. */ for ($i = 0; $i < $days->length; $i++) { $availibilityStr = $availibility[$i]->nodeValue; if (strtolower($availibilityStr) === "ok") { //$calendarDates->add($days[$i]->nodeValue); $dates[] = new Day($days[$i]->nodeValue); } } $calendarDates->add($dates); } return $calendarDates; }