-
Notifications
You must be signed in to change notification settings - Fork 3
/
single-projects.php
518 lines (473 loc) · 20.2 KB
/
single-projects.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
<?php
if (isset($_POST['g-recaptcha-response'])):
require_once('recaptcha/autoload.php');
$recaptcha = new \ReCaptcha\ReCaptcha('6LdZuB8TAAAAADNqj-Iv6YuAdRqJBEzMhJz_ZUmB');
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
$attachments = [];
if (($resp->isSuccess())) {
if (!empty($_POST['email']) && empty($_GET['firstname']) && empty($_GET['lastname'])) {
$file_tmp = $_FILES['file']['tmp_name'];
$file_name = $_FILES['file']['name'];
$file_size = $_FILES['file']['size'];
if (is_uploaded_file($file_tmp)) {
move_uploaded_file($file_tmp, WP_CONTENT_DIR . "/uploads/$file_name");
$attachments = array(WP_CONTENT_DIR . '/uploads/' . $file_name);
}
$pid = $_POST['pid'];
$headers = 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n" .
'Reply-To: ' . $_POST['email'] . "\r\n";
if (isset($_POST['cc']) && $_POST['cc'] == '1') {
$title = __('Contact with the coordinator');
$content = __('First name') . ' i ' . __('Last name') . ': ' . $_POST['fname'] . ' ' . $_POST['lname'] .
'<br>Email: ' . $_POST['email'] .
'<br>' . __('Project') . ': ' . get_the_title($pid) .
'<br>' . __('Message') . ': ' . nl2br($_POST['message']);
} else {
$title = __('Application from the site');
$content = __('First name') . ' i ' . __('Last name') . ': ' . $_POST['fname'] . ' ' . $_POST['lname'] .
'<br>Email: ' . $_POST['email'] .
'<br>' . __('Job') . ': ' . $_POST['job'] .
'<br>' . __('Project') . ': ' . get_the_title($pid) .
'<br>' . __('Message') . ': ' . nl2br($_POST['message']);
}
wp_mail($_POST['email'], $title, $content, $headers, $attachments);
$headers .= 'Cc: [email protected]';
wp_mail(get_field('mail', $pid), $title, $content, $headers, $attachments);
if(!empty($attachments)) {
unlink($attachments[0]);
}
$success = 1;
}
} else {
$success = 2;
}
endif;
?>
<?php get_header() ?>
<?php $src = get_template_directory_uri(); ?>
<?php get_template_part('breadcrumbs'); ?>
<div class="row project-single">
<?php if (have_posts()): ?>
<?php while (have_posts()): the_post(); ?>
<?php
$img = get_field('photo_main');
?>
<div class="small-12 medium-9 columns post-content">
<h1><?php the_title(); ?></h1>
<img src="<?php echo $img['sizes']['large']; ?>" class="mb40" />
<div class="row">
<div class="small-12 medium-9 columns">
<div class="content text-justify">
<?php the_content(); ?>
<?php
$topics = wp_get_post_terms(get_the_ID(), 'filters');
$ret = [];
foreach ($topics as $topic):
if ($topic->parent != icl_object_id(84, 'filters', true) && $topic->parent != icl_object_id(0, 'filters', true)) {
$ret[$topic->parent] = ($ret[$topic->parent] ?? '') . $topic->name . ', ';
}
endforeach;
?>
<div class="mt20 mb20">
<strong><?php _e('Project page updated') ?>:</strong> <?php echo get_the_modified_date(); ?><br />
<?php foreach ($ret as $key => $r): ?>
<strong><?php
$t = get_term($key, 'filters');
echo $t->name;
?>:</strong> <?php echo rtrim($r, ', '); ?><br />
<?php endforeach; ?>
</div>
<?php
$coordinator = get_field('btn_name');
?>
<div class="text-center mt20 mb30">
<a data-open="mailModal2" class="btn red bigger">
<?php
if ($coordinator) {
printf(__('Contact %s - project coordinator'), $coordinator);
} else {
_e('Contact coordinator');
}
?>
</a>
</div>
<ul class="project-links">
<?php
$links = get_field('links');
if ($links):
foreach ($links as $link):
?>
<li>
<?php if ($link['embed'] == true): ?>
<?php if (strstr($link['url'], 'facebook')): ?>
<div class="fb-page" data-href="<?php echo $link['url']; ?>" data-tabs="timeline" data-width="500" data-small-header="true" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"><div class="fb-xfbml-parse-ignore"><blockquote cite="<?php echo $link['url']; ?>"><a href="<?php echo $link['url']; ?>"><?php echo $link['name']; ?></a></blockquote></div></div>
<?php elseif (strstr($link['url'], 'slideshare.net')): ?>
<?php echo wp_oembed_get($link['url']); ?>
<?php elseif (strstr($link['url'], 'youtube')): ?>
<?php echo wp_oembed_get($link['url']); ?>
<?php elseif (strstr($link['url'], 'forum.koduj')): ?>
<div class="show-for-large">
<div class="embed-wrapper">
<a href="<?php echo $link['url']; ?>/" class="btn red embed-link" target="_blank"><?php echo $link['name']; ?></a>
<div id="discourse-comments"></div>
<script>
var discourseUrl = "https://forum.kodujdlapolski.pl/";
function showDiscourseTopic(topic) {
var comments = document.getElementById('discourse-comments');
var iframe = document.getElementById('discourse-embed-frame');
if (iframe) {
iframe.remove();
}
iframe = document.createElement('iframe');
iframe.src = '<?php echo $link['url']; ?>';
iframe.id = 'discourse-embed-frame';
iframe.width = '100%';
iframe.height = '500px';
iframe.frameBorder = '0';
iframe.scrolling = 'yes';
comments.appendChild(iframe);
}
;
showDiscourseTopic('');
</script>
<div class="text-right">
<a href="<?php echo $link['url']; ?>" target="_blank">Otwórz forum w nowym oknie > </a>
</div>
</div>
</div>
<div class="hide-for-large">
<a href="<?php echo $link['url']; ?>"><?php echo $link['name']; ?> > </a>
</div>
<?php elseif (strstr($link['url'], 'docs.google')): ?>
<?php
$url = str_replace('/edit', '/embed', $link['url']);
if (!strstr($url, 'embed')) {
$url .= '/embed';
}
?>
<iframe src="<?php echo $url; ?>?start=false&loop=false&delayms=10000" frameborder="0" width="480" height="375" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>
<?php elseif (strstr($link['url'], 'github')): ?>
<div class="embed-wrapper">
<?php
$ar = explode('/', $link['url']);
?>
<a href="<?php echo $link['url']; ?>/" class="btn red embed-link" target="_blank"><?php _e('Github'); ?> - <?php echo $ar[4]; ?></a>
<h3>GitHub: <?php echo $ar[3] . ' / ' . $ar[4]; ?></h3>
<?php
if (false === ($git_langs = get_transient('github_languages_' . $ar[3] . '_' . $ar[4]))):
$ch = curl_init('https://api.github.com/repos/' . $ar[3] . '/' . $ar[4] . '/languages');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'KdP');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$git_langs = curl_exec($ch);
curl_close($ch);
set_transient('github_languages_' . $ar[3] . '_' . $ar[4], $git_langs, 12 * 3600);
endif;
$obj = json_decode($git_langs);
$i = 0;
$sum = 0;
foreach ($obj as $key => $o) {
$sum += $o;
$i++;
}
$j = 0;
?>
<div class="row large-up-<?php echo $i; ?> languages">
<?php foreach ($obj as $key => $o): ?>
<div class="column"><?php /* <div class="color-dot" style="background:#<?php echo $j * 2; ?>1<?php echo $j; ?>1<?php echo $j; ?><?php echo $j; ?>;"></div> */ ?><?php echo $key; ?> <span><?php echo round($o / $sum * 100, 2); ?>%</span></div>
<?php
$j++;
endforeach;
?>
</div>
<?php
if (false === ($git_issues = get_transient('tmp_github_issues_' . $ar[3] . '_' . $ar[4]))):
$ch = curl_init('https://api.github.com/repos/' . $ar[3] . '/' . $ar[4] . '/issues');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'KdP');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$git_issues = curl_exec($ch);
curl_close($ch);
set_transient('tmp_github_issues_' . $ar[3] . '_' . $ar[4], $git_issues, 12 * 3600);
endif;
$obj = json_decode($git_issues);
$b = 0;
if ($obj):
?>
<div class="issues-wrapper mt20 mb20">
<div class="title-row"><a href="<?php echo $link['url']; ?>/issues/" target="_blank"><?php _e('Issues from GitHub'); ?></a></div>
<?php foreach ($obj as $o): ?>
<?php //print_r($o); ?>
<div class="issue-row">
<div class="title-col">
<a href="<?php echo $o->html_url; ?>" target="_blank"><?php echo $o->title; ?></a>
<div class="meta-data">#<?php echo $o->number; ?> <?php _e('opened on'); ?> <?php echo date_i18n('d M Y', strtotime($o->created_at)); ?> <?php _e('by'); ?> <?php echo $o->user->login; ?> <?php _e('updated on'); ?> <?php echo date_i18n('d M Y', strtotime($o->updated_at)); ?></div>
</div>
<div class="assignee-col">
<?php
if ($o->assignee->gravatar_id) {
$av = $o->assignee->gravatar_id;
} else {
$av = $o->assignee->avatar_url;
}
if ($av):
?>
<img src="<?php echo $av; ?>" />
<?php else: ?>
<?php endif; ?>
</div>
<div class="comments-col">
<i class="icon-comment-o"></i> <?php echo $o->comments; ?>
</div>
</div>
<?php
if ($b == 2) {
break;
}
?>
<?php
$b++;
endforeach;
?>
<a href="<?php echo $link['url']; ?>/issues/" class="sm-link" target="_blank"><?php _e('See more'); ?> <i class="icon-angle-right"></i></a>
</div>
<?php
if (false === ($git_commits = get_transient('github_commits_' . $ar[3] . '_' . $ar[4]))):
$ch = curl_init('https://api.github.com/repos/' . $ar[3] . '/' . $ar[4] . '/commits');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'KdP');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$git_commits = curl_exec($ch);
curl_close($ch);
set_transient('github_commits_' . $ar[3] . '_' . $ar[4], $git_commits, 12 * 3600);
endif;
$obj = json_decode($git_commits);
$b = 0;
if ($obj):
?>
<div class="issues-wrapper mt20 mb20">
<div class="title-row"><a href="<?php echo $link['url']; ?>/commits/" target="_blank"><?php _e('Commits from GitHub'); ?></a></div>
<?php foreach ($obj as $o): ?>
<div class="issue-row">
<div class="title-col">
<a href="<?php echo $o->html_url; ?>" target="_blank"><?php echo $o->commit->message; ?></a>
<div class="meta-data"><?php echo date_i18n('d M Y', strtotime($o->commit->committer->date)); ?> <?php _e('by'); ?> <?php echo $o->commit->committer->name; ?></div>
</div>
<div class="assignee-col">
<?php
if ($o->committer->gravatar_id) {
$av = $o->committer->gravatar_id;
} else {
$av = $o->committer->avatar_url;
}
if ($av):
?>
<img src="<?php echo $av; ?>" />
<?php else: ?>
<?php endif; ?>
</div>
</div>
<?php
if ($b == 2) {
break;
}
?>
<?php
$b++;
endforeach;
?>
<a href="<?php echo $link['url']; ?>/commits/" class="sm-link" target="_blank"><?php _e('See more'); ?> <i class="icon-angle-right"></i></a>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php else: ?>
<a href="<?php echo $link['url']; ?>" class="btn red"><?php echo $link['name']; ?> > </a>
<?php
endif;
?>
<?php else: ?>
<a href="<?php echo $link['url']; ?>" class="btn red"><?php echo $link['name']; ?> > </a>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
</div>
<div class="small-12 medium-3 columns team-list">
<?php
$team = get_field('osoby');
if ($team):
?>
<h3><?php _e('Team'); ?></h3>
<table>
<?php foreach ($team as $member): ?>
<?php if ($member['person']['ID']): ?>
<tr>
<td class="photo">
<?php
//$photo = get_field('photo', 'user_' . $member['person']['ID']);
$photo = get_field('photo', 'user_' . $member['person']['ID']);
$user_photo = $photo['sizes']['thumbnail'];
if (!$user_photo) {
$user_photo = get_avatar_url($member['person']['ID'], array('size' => 105));
}
if (!$user_photo) {
$user_photo = $src . '/images/blank-person2.jpg';
}
?>
<a href="<?php echo get_author_posts_url($member['person']['ID']); ?>"><img src="<?php echo $user_photo; ?>" alt="<?php echo $member['person']['display_name'] ?>" /></a>
</td>
<td class="desc">
<h4><a href="<?php echo get_author_posts_url($member['person']['ID']); ?>"><?php echo $member['person']['display_name'] ?></a></h4>
<div class="function"><?php echo $member['function']; ?></div>
</td>
</tr>
<?php else: ?>
<?php /*
<tr>
<td class="photo">
<a href="#" class="contact"><img src="<?php echo $src; ?>/images/blank-person.jpg" /></a>
</td>
<td class="desc">
<a class="contact open-contact" data-open="mailModal" data-job="<?php echo $member['function']; ?>">Dołącz jako<br /><?php echo $member['function']; ?></a>
</td>
</tr> */ ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php
$terms = get_the_terms(get_the_ID(), 'filters');
if ($terms && !is_wp_error($terms)) :
foreach ($terms as $term) {
if ($term->parent == icl_object_id(84, 'filters', true)) {
?>
<tr>
<td class="photo">
<a data-open="mailModal" data-job="<?php echo $term->name; ?>" class="contact"><img src="<?php echo $src; ?>/images/blank-person.jpg" /></a>
</td>
<td class="desc">
<a class="contact open-contact" data-open="mailModal" data-job="<?php echo $term->name; ?>"><?php _e('Join as'); ?><br /><?php echo $term->name; ?></a>
</td>
</tr>
<?php
}
}
endif;
?>
</table>
</div>
</div>
<?php if (get_field('partners_template') == 'lista'): ?>
<?php
$posts = get_field('partners');
if ($posts):
?>
<h3 class="section-title"><?php _e('Partners'); ?></h3>
<?php
foreach ($posts as $post):
setup_postdata($post);
$logo = get_field('logo');
$url = get_field('url');
$content = get_the_content();
?>
<div class="partner-box">
<?php if ($url): ?>
<div class="text-center">
<a href="<?php echo $url; ?>"><img src="<?php echo $logo['sizes']['medium']; ?>" alt="<?php the_title(); ?>" /></a>
</div>
<?php if (empty($content)): ?>
<h3><a href="<?php echo $url; ?>"><?php the_title(); ?></a></h3>
<?php endif; ?>
<?php else: ?>
<div class="text-center">
<img src="<?php echo $logo['sizes']['medium']; ?>" alt="<?php the_title(); ?>" />
</div>
<?php if (empty($content)): ?>
<h3><?php the_title(); ?></h3>
<?php endif; ?>
<?php endif; ?>
<div class="content">
<?php the_content(); ?>
</div>
</div>
<?php
endforeach;
wp_reset_postdata();
?>
<?php endif; ?>
<?php endif; ?>
<?php
$github_owner = get_field('github_owner');
$github_name = get_field('github_name');
if ($github_name && $github_owner && false):
?>
<h3 class="section-title"><?php _e('Languages used'); ?></h3>
<?php
if (false === ($github_lang = get_transient('github_languages_' . $github_owner . '_' . $github_name))):
set_transient('github_' . $github_owner . '_' . $github_name, $github_lang, 12 * 3600);
endif;
$client = new GitHubClient();
$client->setPage();
$client->setPageSize(2);
$issues = $client->issues->listIssues($github_owner, $github_name);
echo "Count: " . count($commits) . "\n";
foreach ($commits as $commit) {
/* @var $commit GitHubCommit */
echo get_class($commit) . " - Sha: " . $commit->getSha() . "\n";
}
$commits = $client->getNextPage();
echo "Count: " . count($commits) . "\n";
foreach ($commits as $commit) {
/* @var $commit GitHubCommit */
echo get_class($commit) . " - Sha: " . $commit->getSha() . "\n";
}
//echo 'https://api.github.com/repos/'.$github_owner.'/'.$github_name.'/languages';
print_r($json);
$obj = json_decode($json);
print_r($obj);
?>
<?php endif; ?>
</div>
<div class="small-12 medium-3 columns post-author">
<?php get_template_part('sidebar'); ?>
</div>
<?php if (get_field('partners_template') == 'logo'): ?>
<div class="small-12 columns mb50">
<?php
$posts = get_field('partners');
if ($posts):
?>
<h3 class="section-title"><?php _e('Partners'); ?></h3>
<div class="row small-up-2 medium-up-4 large-up-6 mt25">
<?php
foreach ($posts as $post):
setup_postdata($post);
$logo = get_field('logo');
$url = get_field('url');
?>
<div class="column">
<div class="partner-wrapper text-center">
<?php if ($url): ?>
<a href="<?php echo $url; ?>"><img src="<?php echo $logo['sizes']['medium']; ?>" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<img src="<?php echo $logo['sizes']['medium']; ?>" alt="<?php the_title(); ?>" />
<?php endif; ?>
</div>
</div>
<?php
endforeach;
wp_reset_postdata();
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_footer() ?>