Changeset 326446
- Timestamp:
- 12/27/2010 07:51:44 PM (15 years ago)
- Location:
- flickrstream/trunk
- Files:
-
- 2 edited
-
flickrstream.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
flickrstream/trunk/flickrstream.php
r322861 r326446 1 1 <?php 2 3 2 /* 4 3 Plugin Name: flickrStream 5 4 Plugin URI: http://timomontalto.com/flickrstream/ 6 5 Description: Shows pictures from a flickr user photostream 7 Version: 0. 26 Version: 0.5 8 7 License: GPL 9 8 Author: Timo Montalto … … 11 10 */ 12 11 function get_flickrStream() { 12 13 if (false === ( $ausgabe = get_transient('bilder_cache') ) ) { 14 15 // Parameter fuer API call werden zusammengestellt 13 16 $params_old = array( 14 17 'api_key' => '4ef2fe2affcdd6e13218f5ddd0e2500d', … … 19 22 ); 20 23 24 // Options aus der Datenbank ziehen 21 25 $shitname = get_option('flickrStream_flickrid'); 22 26 $zahl = get_option('flickrStream_display_numitems'); 27 $imagesize = get_option('flickrStream_display_imagesize'); 28 $cachetime = get_option('flickrStream_display_cachetime'); 23 29 24 $params2 = array(); 30 // Parameter im Array mit den Daten der Optionspage updaten 31 $params = array(); 25 32 foreach($params_old as $key => $value) { 26 33 if($key == 'user_id') { 27 $params2[''.$key.''] = $shitname; 28 }else{ 29 $params2[''.$key.''] = $value; 30 } 31 } 32 33 34 $params = array(); 35 foreach($params2 as $key => $value) { 36 if($key == 'per_page') { 37 $params[''.$key.''] = $zahl; 34 $params[''.$key.''] = $shitname; 35 }elseif ($key == 'per_page') { 36 $params[''.$key.''] = $zahl; 38 37 }else{ 39 38 $params[''.$key.''] = $value; … … 41 40 } 42 41 42 43 43 $encoded_params = array(); 44 44 45 45 foreach ($params as $k => $v){ 46 47 46 $encoded_params[] = urlencode($k).'='.urlencode($v); 48 47 } 49 48 50 49 // API Call und daten in $rsp speichern 51 50 $url = "http://api.flickr.com/services/rest/?".implode('&', $encoded_params); 52 53 51 $rsp = file_get_contents($url); 54 55 52 $rsp_obj = unserialize($rsp); 56 53 57 $imagesize = get_option('flickrStream_display_imagesize'); 58 54 // Bildergr?§e abrufen 59 55 if ($imagesize == "square") { 60 56 $imgurl = "_s.jpg"; 61 57 } elseif ($imagesize == "thumbnail") { 62 58 $imgurl = "_t.jpg"; 59 } elseif ($imagesize == "small") { 60 $imgurl = "_m.jpg"; 63 61 } elseif ($imagesize == "medium") { 64 $imgurl = "_m.jpg"; 62 $imgurl = "_z.jpg"; 63 } elseif ($imagesize == "large") { 64 $imgurl = "_b.jpg"; 65 65 } 66 66 // Wenn der Aufruf funktioniert hat... 67 67 if ($rsp_obj['stat'] == 'ok'){ 68 68 69 69 for($count = 0; $count < $zahl; $count++) 70 70 { 71 echo "<div class='flickrsingle container" . $count . "'><img class='flickrimage flickrpic" . $count . "' src='http://farm" . $rsp_obj['photos']['photo'][$count]['farm'] . ".static.flickr.com/" . $photo_server1 = $rsp_obj['photos']['photo'][$count]['server'] . "/" . $photo_id1 = $rsp_obj['photos']['photo'][$count]['id'] . "_" . $photo_secret1 = $rsp_obj['photos']['photo'][$count]['secret'] . $imgurl . "' />"; 72 echo "<span class='flickrtext subline" . $count . "'>" . $photo_title1 = $rsp_obj['photos']['photo'][$count]['title'] . "</span></div>"; 71 $ausgabe .= "<div class='flickrsingle container" . $count . "'><a href='http://farm" . $rsp_obj['photos']['photo'][$count]['farm'] . ".static.flickr.com/" . $photo_server1 = $rsp_obj['photos']['photo'][$count]['server'] . "/" . $photo_id1 = $rsp_obj['photos']['photo'][$count]['id'] . "_" . $photo_secret1 = $rsp_obj['photos']['photo'][$count]['secret'] . "_z.jpg'><img class='flickrimage flickrpic" . $count . "' src='http://farm" . $rsp_obj['photos']['photo'][$count]['farm'] . ".static.flickr.com/" . $photo_server1 = $rsp_obj['photos']['photo'][$count]['server'] . "/" . $photo_id1 = $rsp_obj['photos']['photo'][$count]['id'] . "_" . $photo_secret1 = $rsp_obj['photos']['photo'][$count]['secret'] . $imgurl . "' title='" . $photo_title1 = $rsp_obj['photos']['photo'][$count]['title'] . "' /></a> <span class='flickrtext subline" . $count . "'>" . $photo_title1 = $rsp_obj['photos']['photo'][$count]['title'] . "</span></div>"; 73 72 } 74 73 75 74 }else{ 76 75 // ...sonst erscheint Hinweis, das der Aufruf fehlschlug 77 76 echo "Aufruf fehlgeschlagen!"; 78 77 } 78 $cachetime = "60*60*" . $cachetime; 79 set_transient('bilder_cache', $ausgabe, $cachetime); 80 } 81 82 echo get_transient('bilder_cache'); 83 79 84 80 85 } 81 86 82 87 function flickrStream_subpanel() { 83 88 if (isset($_POST['save_flickrStream_settings'])) { 89 90 // Daten werden aus Input Feldern gelesen 84 91 $option_flickrid = $_POST['flickr_id']; 85 92 $option_display_numitems = $_POST['display_numitems']; 86 93 $option_display_imagesize = $_POST['display_imagesize']; 87 94 $option_display_cachetime = $_POST['display_cachetime']; 95 // Daten werden in die Options Tabelle geschrieben 88 96 update_option('flickrStream_flickrid', $option_flickrid); 89 97 update_option('flickrStream_display_numitems', $option_display_numitems); 90 98 update_option('flickrStream_display_imagesize', $option_display_imagesize); 91 99 update_option('flickrStream_display_cachetime', $option_display_cachetime); 100 // Cache reseted 101 delete_transient('bilder_cache'); 92 102 ?> <div class="updated"><p>flickrStream Einstellungen gespeichert</p></div> <?php 93 103 } 94 95 104 ?> 96 97 105 <div class="wrap"> 98 106 <h2>flickrStream Einstellungen</h2> 99 100 107 <form method="post"> 101 108 <table class="form-table"> … … 108 115 <th scope="row">Bilder anzeigen</th> 109 116 <td> 110 111 117 Wieviele? 112 118 <select name="display_numitems" id="display_numitems"> … … 138 144 <option <?php if(get_option('flickrStream_display_imagesize') == 'small') { echo 'selected'; } ?> value="small">small</option> 139 145 <option <?php if(get_option('flickrStream_display_imagesize') == 'medium') { echo 'selected'; } ?> value="medium">medium</option> 146 <option <?php if(get_option('flickrStream_display_imagesize') == 'large') { echo 'selected'; } ?> value="large">large</option> 140 147 </select> 141 148 Cache-Zeit 149 <select name="display_cachetime" id="display_cachetime"> 150 <option <?php if(get_option('flickrStream_display_cachetime') == '1') { echo 'selected'; } ?> value="1">1</option> 151 <option <?php if(get_option('flickrStream_display_cachetime') == '3') { echo 'selected'; } ?> value="3">3</option> 152 <option <?php if(get_option('flickrStream_display_cachetime') == '6') { echo 'selected'; } ?> value="6">6</option> 153 <option <?php if(get_option('flickrStream_display_cachetime') == '8') { echo 'selected'; } ?> value="8">8</option> 154 <option <?php if(get_option('flickrStream_display_cachetime') == '10') { echo 'selected'; } ?> value="10">10</option> 155 <option <?php if(get_option('flickrStream_display_cachetime') == '12') { echo 'selected'; } ?> value="12">12</option> 156 <option <?php if(get_option('flickrStream_display_cachetime') == '18') { echo 'selected'; } ?> value="18">18</option> 157 <option <?php if(get_option('flickrStream_display_cachetime') == '24') { echo 'selected'; } ?> value="24">24</option> 158 </select> 159 Stunden 142 160 </td> 143 </tr> 144 161 </tr> 145 162 </table> 146 <p>Die Ausgabe erfolgt durch die Platzierung von <strong> get_flickrStream();</strong> im Template</p>163 <p>Die Ausgabe erfolgt durch die Platzierung von <strong><?php if ( function_exists('get_flickrStream') ) { get_flickrStream() } ?></strong> im Template</p> 147 164 <div class="submit"> 148 165 <input type="submit" name="save_flickrStream_settings" value="<?php _e('Speichern', 'save_flickrStream_settings') ?>" /> … … 150 167 </form> 151 168 </div> 152 153 169 <?php } 154 155 156 170 function flickrStream_admin_menu() { 157 171 if (function_exists('add_options_page')) { -
flickrstream/trunk/readme.txt
r322861 r326446 5 5 Requires at least: 3.0 6 6 Tested up to: 3.0.3 7 Stable tag: 0. 27 Stable tag: 0.5 8 8 9 9 Einfaches Wordpress Plugin, dass den Photostream eines flickr Users ausliest und die Bilder mit Titel ausgibt. … … 25 25 == Changelog == 26 26 27 = 0.5 = 28 * Performance upgrade 29 * Chache added 30 * size fix 31 27 32 = 0.2 = 28 33 * Rechtschreibfehler behoben
Note: See TracChangeset
for help on using the changeset viewer.