-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeacher.php
executable file
·51 lines (42 loc) · 1005 Bytes
/
Teacher.php
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
<?php
/**
* 教师实体类
*/
class Teacher {
var $position;
var $name;
var $phone;
var $email;
var $office;
function __construct() {
}
public static function parse(DOMElement $row) {
$cells_list = $row->getElementsByTagName('td');
if($cells_list->length != 5) {
return null;
}
$teacher = new Teacher();
foreach ($cells_list as $cell) {
$div_list = $cell->getElementsByTagName('div');
$div = $div_list->item(0);
$class = $div->getAttribute('class');
if (strpos($class, 'ofc') !== false) {
$teacher->office = $div->nodeValue;
}
else if (strpos($class, 'name') !== false) {
$teacher->name = $div->nodeValue;
}
else if (strpos($class, 'type') !== false) {
$teacher->position = $div->nodeValue;
}
else if (strpos($class, 'max-col') !== false) {
$teacher->email = $div->nodeValue;
}
else {
$teacher->phone = $div->nodeValue;
}
}
return $teacher;
}
}
?>