-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedin_profile_html.php
executable file
·143 lines (133 loc) · 4.47 KB
/
linkedin_profile_html.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
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
<?php
/**
* 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/>.
*/
/**
* LinkedIn profile HTML
*
* Parses a profile page using LinkedInProfile and returns HTML code based on div tags
*
* @author Guillaume Viguier-Just <[email protected]>
* @licence http://www.gnu.org/licenses/gpl-3.0.txt
*/
require_once(dirname(__FILE__).'/linkedin_profile.php');
class LinkedInProfileHTML {
/**
* Profile
* @var LinkedInProfile
*/
protected $_profile = null;
/**
* Constructor
*
* @param LinkedInProfile Profile to be based on
*/
public function __construct($profile) {
if($profile instanceof LinkedInProfile) {
$this->_profile = $profile;
}
}
/**
* Formats the profile identity
*
* @return string Profile identity formatted in HTML
*/
protected function format_identity() {
$p = $this->_profile;
$out = '<div class="linkedin-identity">';
$out .= '<div class="linkedin-identity-firstname">'.$p->firstname.'</div>';
$out .= '<div class="linkedin-identity-lastname">'.$p->lastname.'</div>';
$out .= '<div class="linkedin-identity-currentstatus">'.$p->current_status.'</div>';
$out .= '<div class="linkedin-identity-currentlocality">'.$p->current_locality.'</div>';
return $out;
}
/**
* Formats an experience
*
* @param object Experience
* @return string Experience formatted in HTML
*/
protected function format_experience($experience) {
$out = '<div class="linkedin-experience">';
$out .= '<div class="linkedin-experience-title">'.$experience->title.'</div>';
$out .= '<div class="linkedin-organization">';
$out .= '<div class="linkedin-organization-title">';
if($experience->organization->link) {
$out .= '<a href="'.$experience->organization->link.'">';
}
$out .= $experience->organization->name;
if($experience->organization->link) {
$out .= '</a>';
}
$out .= '</div>';
$out .= '<div class="linkedin-organization-sector">'.$experience->organization->sector.'</div>';
$out .= '</div>';
$out .= '<div class="linkedin-period">';
$out .= '<div class="linkedin-period-start">'.$experience->period->start.'</div>';
$out .= '<div class="linkedin-period-end">'.$experience->period->end.'</div>';
$out .= '</div>';
$out .= '<div class="linkedin-experience-description">'.$experience->description.'</div>';
$out .= '</div>';
return $out;
}
/**
* Formats an education
*
* @param object Education
* @return string Education formatted in HTML
*/
protected function format_education($education) {
$out = '<div class="linkedin-education">';
$out .= '<div class="linkedin-education-title">'.$education->title.'</div>';
$out .= '<div class="linkedin-education-degree">'.$education->degree.'</div>';
$out .= '<div class="linkedin-education-major">'.$education->major.'</div>';
$out .= '<div class="linkedin-period">';
$out .= '<div class="linkedin-period-start">'.$education->period->start.'</div>';
$out .= '<div class="linkedin-period-end">'.$education->period->end.'</div>';
$out .= '</div>';
$out .= '<div class="linkedin-education-notes">'.$education->notes.'</div>';
$out .= '</div>';
return $out;
}
/**
* Formats skills and interests
*
* @return string Skills and interests formatted in HTML
*/
protected function format_skills_interests() {
$p = $this->_profile;
$out = '<div class="linkedin-skills">'.$p->skills.'</div>';
$out .= '<div class="linkedin-interests">'.$p->interests.'</div>';
return $out;
}
/**
* Returns the profile in HTML as a string
*
* @return string
*/
public function __toString() {
$out = '';
$out .= $this->format_identity();
$experiences = $this->_profile->experiences;
foreach($experiences as $experience) {
$out .= $this->format_experience($experience);
}
$educations = $this->_profile->education;
foreach($educations as $education) {
$out .= $this->format_education($education);
}
$out .= $this->format_skills_interests();
return $out;
}
}