This repository has been archived by the owner on Dec 14, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathegg_showflickrset.php
130 lines (91 loc) · 3.99 KB
/
egg_showflickrset.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
<?php
// <?php This helps to show syntax highlighting in Textmate when c&p code from the plugin composer
function egg_set($atts)
{
global $isFeed; // Set $isFeed to 1 to alter the feed display
if (is_array($atts)) extract($atts);
$set = isset($set) ? $set : '72157618717025654';
$max = isset($max) ? $max : '20';
$align = isset($align) ? ' '.$align : ' full';
$desc = isset($desc) ? $desc : 'yes';
/* Get Infos */
$params = array(
'api_key' => '44fb49dfa041df6dac938a2c25166288',
'method' => 'flickr.photosets.getInfo',
'photoset_id' => $set,
'format' => 'php_serial'
);
$encoded_params = array();
foreach ($params as $k => $v) {
$encoded_params[] = urlencode($k).'='.urlencode($v);
}
$url = "http://api.flickr.com/services/rest/?".implode('&', $encoded_params);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$return = unserialize($output);
$title = $return['photoset']['title']['_content'];
$description = $return['photoset']['description']['_content'];
$rest = $return['photoset']['photos']-20;
$owner = $return['photoset']['owner'];
/* Get Infos END */
/* Get Photos */
$params = array(
'api_key' => '44fb49dfa041df6dac938a2c25166288',
'method' => 'flickr.photosets.getPhotos',
'photoset_id' => $set,
'per_page' => $max,
'format' => 'php_serial'
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k).'='.urlencode($v);
}
$url = "http://api.flickr.com/services/rest/?".implode('&', $encoded_params);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$photos = unserialize($output);
$photos = $photos['photoset']['photo'];
$i = 0;
$o = '<h3 class="photoset">Fotosammlung: »<a href="http://www.flickr.com/photos/'.$owner.'/sets/'.$set.'">'.$title.'</a>«</h3>';
if ($desc=="yes") {
$o .= ($description==="") ? "" : '<p class="photoset">'.$description."</p>";
}
$o .= '<ul class="photoset'.$align.'">';
foreach ($photos as $photo) {
$i++;
$o .= "<li>";
$o .= '<a href="http://www.flickr.com/photos/'.$owner.'/'.$photo['id'].'/in/set-'.$set.'/"><img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_s.jpg" alt="'.$photo['title'].'">';
$o .= ($isFeed) ? "" : '<img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_m.jpg" alt="" class="large">';
$o .= '</a>';
$o .= "</li>";
}
if ($i==$max) {
$o .='<li class="lastone"><a href="http://www.flickr.com/photos/'.$owner.'/sets/'.$set.'">'.$rest.' weitere Fotos anzeigen…</a></li>';
}
$o .="</ul>";
return $o;
}
/*
--- PLUGIN METADATA ---
Name: egg_showflickrset
Version: 0.21
Type: 0
Description: Displays a flickr set
Author: Eric Eggert
Link: http://yatil.de/
--- BEGIN PLUGIN HELP ---
<h1>egg_flickrset</h1>
<p>Takes the following parameters:
<dl><dt><code>set</code></dt><dd>ID of the set to display, you can extract that easily from the URL: <code>http://www.flickr.com/photos/yatil/sets/<strong> 72157618717025654 </strong>/</code></dd><dt><code>max</code></dt><dd>Shows x photos. If there are more photos in a set, a link to the set is included.</dd><dt><code>align</code></dt><dd>Adds an additional class to the ul, to use with CSS.</dd><dt><code>desc</code></dt><dd>If description should be included the value is <code>yes</code> (default value), else <code>no</code>.</dd></dl>
<p>Some things are still hardcoded, like german text strings or the double photo for CSS tricks. This will be changed at some time in the future.
--- END PLUGIN HELP & METADATA ---
*/
?>